Arch Yafu2 安装指南
2024-02-09 23:10:53

YAFU is the result of an ongoing hobby project to understand how to factor
large integers, and how to factor them fast.

参考: How I install YAFU version 2 onto my Ubuntu Machines by EdH
Yafu2 官方 thread: YAFU 2.0

0. 前置依赖

先准备一个空文件夹, 为了方便依赖和yafu2本体装在一个文件夹下

0.1 GMP

  1. 找到 https://gmplib.org/download/gmp 下最新版本并下载(比如我现在是 v6.2.1)
  2. 解压改名
  3. ./configuremake
1
2
3
4
5
6
7
8
wget https://gmplib.org/download/gmp/gmp-6.2.1.tar.bz2
tar jxvf gmp-6.2.1.tar.bz2
mv gmp-6.2.1 gmp
cd gmp
./configure
make
sudo make install
make check

0.2 GMP-ECM

  1. 找到 https://gitlab.inria.fr/zimmerma/ecm/-/releases 的最新 release (现在是 v7.0.5) 然后复制他的下载链接(ecm-x.y.z.tar.gz)并下载
  2. 解压改名
  3. configuremake
1
2
3
4
5
6
7
8
wget https://gitlab.inria.fr/zimmerma/ecm/uploads/89f6f0d65d3e980cef33dc922004e4b2/ecm-7.0.5.tar.gz
tar zxvf ecm-7.0.5.tar.gz
mv ecm-7.0.5 gmp-ecm
cd gmp-ecm
./configure
make
sudo make install
make check

0.3 msieve

  1. 找到 https://sourceforge.net/projects/msieve/files/msieve 的最新版本 (现在是 v1.53) 然后下载源码 (msievexyz_src.tar.gz或者msievexyz.tar.gz)
  2. 解压改名和make
1
2
3
4
5
wget https://sourceforge.net/projects/msieve/files/msieve/Msieve%20v1.53/msieve153_src.tar.gz/download
tar zxvf download
mv msieve-1.53 msieve
cd msieve
make all

0.4 ytools

  1. git clone
  2. 改 Makefile:
    CC = gcc-7.3.0 => CC = gcc
  3. make
1
2
3
4
git clone [email protected]:bbuhrow/ytools.git # or git clone https://github.com/bbuhrow/ytools
cd ytools
vim Makefile
make

0.5 ysieve

  1. git clone
  2. make
1
2
3
git clone [email protected]:bbuhrow/ysieve.git # or git clone https://github.com/bbuhrow/ysieve
cd ysieve
make

1. 安装 Yafu2

  1. git clone git clone [email protected]:bbuhrow/yafu.git
  2. 修改 Makefile:
    1
    2
    3
    4
    5
    INC += -I../gmp_install/gmp-6.2.0/include
    LIBS += -L../gmp_install/gmp-6.2.0/lib

    INC += -I../ecm_install/include/
    LIBS += -L../ecm_install/lib/
    to
    1
    2
    3
    4
    5
    INC += -I/usr/local/include/
    LIBS += -L/usr/local/include/

    #INC += -I../ecm_install/include/
    #LIBS += -L../ecm_install/lib/
  3. 执行 lscpu 主要看核数和那些 cpu flag
  4. 修改 yafu.ini
    1
    2
    3
    % threads=1
    ggnfs_dir=..\..\ggnfs-bin\x64\
    ecm_path=..\..\gmp-ecm\bin\mingw\ecm.exe
    to
    1
    2
    3
    threads=<# CPU 数量>
    ggnfs_dir=../ggnfs/bin/
    ecm_path=/usr/local/bin/ecm
    这里 ggnfs_dir 没装也没问题
  5. [可选] 可以在下一步的 make 命令加上那些 CPU flag, 比如 make NFS=1 USE_SSE41=1 USEAVX2=1, 不过这也可能导致问题, 我电脑上就只能编 NFS=1
  6. make NFS=1

2 Troubleshooting

2.1 SIQS.c:2448: undefined reference to 'nextRoots_32k_avx2_intrin'

因为没有清理之前不同 flag 编译结果导致的, 在下一次 make 前执行 make clean + 那些 flag 就行

2.2 msieve 找不到 gzlib function

具体日志如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/usr/bin/ld: ../msieve//libmsieve.a(savefile.o): in function `savefile_open':
savefile.c:(.text+0x132): undefined reference to `gzopen64'
/usr/bin/ld: savefile.c:(.text+0x23e): undefined reference to `gzopen64'
/usr/bin/ld: savefile.c:(.text+0x269): undefined reference to `gzopen64'
/usr/bin/ld: ../msieve//libmsieve.a(savefile.o): in function `savefile_close':
savefile.c:(.text+0x311): undefined reference to `gzclose'
/usr/bin/ld: ../msieve//libmsieve.a(savefile.o): in function `savefile_write_line':
savefile.c:(.text+0x3f9): undefined reference to `gzputs'
/usr/bin/ld: ../msieve//libmsieve.a(savefile.o): in function `savefile_flush':
savefile.c:(.text+0x46c): undefined reference to `gzputs'
/usr/bin/ld: ../msieve//libmsieve.a(savefile.o): in function `savefile_eof':
savefile.c:(.text+0x339): undefined reference to `gzeof'
/usr/bin/ld: ../msieve//libmsieve.a(savefile.o): in function `savefile_read_line':
savefile.c:(.text+0x39c): undefined reference to `gzgets'
/usr/bin/ld: ../msieve//libmsieve.a(savefile.o): in function `savefile_rewind':
savefile.c:(.text+0x499): undefined reference to `gzrewind'

在 yafu 的 Makefile 里面加上 LIBS+= -lc -lz