-   YAFU (
-   -   Compiling YAFU for Windows using mingw (

bsquared 2017-04-22 01:36

Compiling YAFU for Windows using mingw
Here is as close as I can get to a recipe for compiling your own copy of YAFU for windows. I have done this for Window 10 and versions of the tools available as of this post date.

Note that you can also build YAFU using the Microsoft Visual Studio environment - I will start a separate thread on that path.

[U]Step 1: Install mingw-x64 and msys[/U]
These are the main tools that get you close to a linux environment on windows.
[URL=""]This[/URL] is a good guide.
The basics steps are:
1) Go to [url][/url] download the installer and run it. Configure it for x86_64 architecture, win32 threading, and seh exceptions. Install to C:\mingw-w64 (or similar)
2) Go to [url][/url] download the mingw-builds-install.exe and install the latest version to c:\ to create c:\msys
There is a msys package manager where you can select libraries/packages to install. I chose most of the ones dealing with compression and tcl/tk; they can come in handy. You won't need gmp, as we will compile/install the latest version later.
3) create an empty c:\msys\mingw folder
4) Edit C:\msys\etc\fstab to add the line C:/MinGW-W64/mingw64 /mingw
and optionally a path to mount your homedirectory
5) download the latest 64-bit [URL=""]yasm[/URL] and save it as c:\msys\bin\yasm.exe
6) Other optional stuff - see Ross's guide

[U]Step 2: create a projects folder[/U]
Somewhere in your home directory on the C drive (that you have hopefully mounted in /etc/fstab so you can navigate to it in an msys terminal), create a top level directory where all necessary dependencies will go. I call mine /projects/factoring.

Create the following empty directories:

[U]Step 3: install gmp[/U]
1) Go to [url][/url] and download the latest source tarball.
2) Put it in your gmp/ folder.
3) Unzip it. (This was almost the most time consuming part for me, as it took me a while to find something that would decompress the .lz file. Eventually [url][/url] worked.)
In msys, extract the archive with e.g., the command tar -xvf gmp-6.1.2.tar
4) Navigate to the newly created gmp/gmp-6.1.2 folder and run the command ./configure --prefix=/path/to/your/gmp/folder/install-6.1.2
The prefix argument specifies where all of the installed libraries will go. The default I think is /usr/lib, which may or may not exist in the mounted filesystem.
My exact command was ./configure --prefix=/home/Ben/projects/factoring/gmp/install-6.1.2
You can find out what your current path is by running the command 'pwd' in the msys terminal.
5) Run make
6) Run make install

[U]Step 4: install ecm[/U]
1) Go to [url][/url] and download the latest source tarball. For me it was 7.0.4
2) Put it in your ecm/ folder.
3) Run the command tar -xvzf ecm-7.0.4.tar.gz
4) Go into the new directory and run ./configure --prefix=/path/to/your/ecm/folder/install-6.1.2 --with-gmp=/path/to/your/gmp/folder/install-6.1.2
This both tells it where to put new ecm libraries and where to find your gmp libraries.
5) run make
6) run make install

[U]Step 5: install msieve[/U]
1) Go to [url][/url] and click download snapshot to get the latest msieve source
2) I had to edit the Makefile to point to the gmp and ecm libraries.
Find and change lines to make them look like this:
-I. -Iaprcl -Iinclude -Ignfs -Ignfs/poly -Ignfs/poly/stage1 \
-I../gmp/install-6.1.2/include/ -I../ecm/install-7.0.4/include/

ifeq ($(ECM),1)
LIBS += -L../gmp/install-6.1.2/lib -L../ecm/install-7.0.4/lib -lecm
3) Navigate to the top level msieve/ directory in msys and run 'make all ECM=1 NO_ZLIB=1 '
If you want CUDA that's your business :) Maybe we can sort out how to get msieve-cuda working with yafu in this thread. Right now it isn't supported.

[U]Step 6: install yafu[/U]
1) Go to [url][/url] and click download snapshot to get the latest yafu source
2) Edit the Makefile.mingw to point to the gmp and ecm libraries.
Find and change lines to make them look like this:
INC += -I../gmp/install-6.1.2/include/
LIBS += -L../gmp/install-6.1.2/lib/

INC += -I../ecm/install-7.0.4/include
LIBS += -L../ecm/install-7.0.4/lib

3) run 'make -f Makefile.mingw x86_64 NFS=1 USE_SSE41=1'
or USE_AVX2 if your computer supports it. or omit both if it supports neither.
4) get the 64-bit ggnfs windows binaries and put them somewhere next to the other tools, e.g., /project/factoring/ggnfs
5) edit yafu.ini to point to the ggnfs directory and to the ecm binary created in Step 2.

Hopefully all of that worked and you now have a nice factoring environment... if not feel free to ask questions here.

Happy factoring!

Stargate38 2017-04-24 22:09

When I get to Step 1, Part 2 (running mingw-builds-install.exe), I get the following error message:

Cannot download repository.txt [0]

How do I get it to successfully download "repository.txt"?

bsquared 2017-04-24 22:30

I got that message too, and I can't remember how I got around it. I may have just tried again later and had it work.

Or, searching I found this thread:

which refers to this thread

whence you can download the 64-bit win32-seh toolchain directly.

Stargate38 2017-04-24 23:11

I'm talking about the step after that ([url][/url]).

bsquared 2017-04-24 23:57

[QUOTE=Stargate38;457429]I'm talking about the step after that ([url][/url]).[/QUOTE]

You could try getting one of the pre-packaged builds in the list of "msys+7za+wget+svn+git+" type links on that page. Extract to e.g., C:\msys

skan 2017-04-27 23:10

Could you upload the resulting binaries, please?

skan 2017-05-09 14:45

We just also need a newer version of ggnfs or being able to compile it.

Jayder 2017-10-07 00:56

I've run into issues at step 5, installing msieve. I've edited the Makefile as instructed, and I believe everything else is in the right place. Hopefully I am not revealing any sensitive information here:

[CODE]$ make all ECM=1 NO_ZLIB=1
rm -f libmsieve.a
ar r libmsieve.a aprcl/mpz_aprcl32.o common/filter/clique.o common/filter/filter.o common/filter/merge.o common/filter/merge_post.o common/filter/merge_pre.o common/filter/merge_util.o common/filter/singleton.o common/lanczos/lanczos.o common/lanczos/lanczos_io.o common/lanczos/lanczos_matmul0.o common/lanczos/lanczos_matmul1.o common/lanczos/lanczos_matmul2.o common/lanczos/lanczos_pre.o common/lanczos/lanczos_vv.o common/lanczos/matmul_util.o common/smallfact/gmp_ecm.o common/smallfact/smallfact.o common/smallfact/squfof.o common/smallfact/tinyqs.o common/batch_factor.o common/cuda_xface.o common/dickman.o common/driver.o common/expr_eval.o common/hashtable.o common/integrate.o common/minimize.o common/minimize_global.o common/mp.o common/polyroot.o common/prime_delta.o common/prime_sieve.o common/savefile.o common/strtoll.o common/thread.o common/util.o mpqs/gf2.qo mpqs/mpqs.qo mpqs/poly.qo mpqs/relation.qo mpqs/sieve.qo mpqs/sqrt.qo mpqs/sieve_core_generic_32k.qo mpqs/sieve_core_generic_64k.qo gnfs/poly/ gnfs/poly/ gnfs/poly/ gnfs/poly/ gnfs/poly/ gnfs/poly/ gnfs/poly/stage1/ gnfs/poly/stage1/ gnfs/poly/stage2/ gnfs/poly/stage2/ gnfs/poly/stage2/ gnfs/poly/stage2/ gnfs/poly/stage2/ gnfs/poly/stage2/ gnfs/poly/stage2/ gnfs/poly/stage2/ gnfs/poly/stage2/ gnfs/poly/stage2/ gnfs/poly/stage2/ gnfs/filter/ gnfs/filter/ gnfs/filter/ gnfs/sieve/ gnfs/sieve/ gnfs/sqrt/ gnfs/sqrt/ gnfs/ gnfs/ gnfs/ gnfs/ gnfs/ gnfs/poly/stage1/ gnfs/poly/stage1/
C:\MinGW-W64\mingw64\bin\ar.exe: creating libmsieve.a
ranlib libmsieve.a
gcc -O3 -fomit-frame-pointer -march=native -D_FILE_OFFSET_BITS=64 -DNDEBUG -D_LARGEFILE64_SOURCE -Wall -W -DMSIEVE_SVN_VERSION=""exported"" -I. -Iaprcl -Iinclude -Ignfs -Ignfs/poly -Ignfs/poly/stage1 -I../gmp/install-6.1.2/include/ -I../ecm/install-7.0.4/include/ -DHAVE_GMP_ECM -DNO_ZLIB demo.c -o msieve \
libmsieve.a -L../gmp/install-6.1.2/lib -L../ecm/install-7.0.4/lib -lecm -ldl -lgmp -lm -lpthread
demo.c: In function 'print_usage':
<command-line>:0:20: error: 'exported' undeclared (first use in this function)
demo.c:86:6: note: in expansion of macro 'MSIEVE_SVN_VERSION'
<command-line>:0:20: note: each undeclared identifier is reported only once for each function it appears in
demo.c:86:6: note: in expansion of macro 'MSIEVE_SVN_VERSION'
demo.c: In function 'main':
demo.c:448:13: warning: this statement may fall through [-Wimplicit-fallthrough=]
demo.c:449:6: note: here
case '2': /* fall through */
Makefile:276: recipe for target `all' failed
make: *** [all] Error 1[/CODE]

jasonp 2017-10-08 12:24

Sounds like the 'svnversion' command in the makefile didn't run, or failed. Even if you didn't use subversion to check out the source, there should have been a fallback path for that.

Jayder 2017-10-09 05:07

I noticed an error in the following, but I think I had already accounted for it. I'll mention it now, though:
[QUOTE=bsquared;457233]4) Go into the new directory and run ./configure --prefix=/path/to/your/ecm/folder/install-6.1.2 --with-gmp=/path/to/your/gmp/folder/install-6.1.2
The ecm install folder should be, 'install-7.0.4'.

I deleted my msieve folder and started that step from scratch, and I ran into different problems. I then tried again starting from step 2, and received the same second problem. Could it be a problem with msys or mingw if gmp and gmp-ecm both compile successfully? Is it an issue with me, or with msieve/yafu?

Here is my full log for steps 5 and 6: [url][/url] (You may notice that I kept the ecm folder as 6.1.2 but it is properly referenced)

There is a bit of reading between the lines in this guide. I was able to fill in a few of the blanks, but perhaps I'm missing something that isn't explicitly stated, or isn't easily searchable.

Thanks for your time, jasonp.

Jayder 2017-10-19 01:15

I've reverted to yafu 1.33 since so much time is wasted on poly select due to the bug with 1.34. If anybody would be so kind as to help me with the problems outlined in my post above, I'd be very grateful. Could someone perhaps try following the instructions themselves to see if it is an error on my side or if it is something else? It's curious that no one in this thread has posted to say they have successfully compiled it. Of course msieve is compilable, but it would seem that we're missing something.

I know you guys are busy, and I don't want to be one of those nags. Whether or not you have time to help, thank you.

All times are UTC. The time now is 16:17.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.