mersenneforum.org  

Go Back   mersenneforum.org > Extra Stuff > Linux

Reply
 
Thread Tools
Old 2017-08-28, 16:09   #1
Prime95
P90 years forever!
 
Prime95's Avatar
 
Aug 2002
Yeehaw, FL

2×11×349 Posts
Default Help building GMP for prime95 29.3

I'm looking at using GMP in prime95 v29.3. I can build the library under linux and Mac OS X (and I assume FreeBSD).

I've tried to create Windows 32-bit and 64-bit DLLs without success. I tried using Mingw-w64 and Msys2 as well as Cygwin. One OS was 32-bit Windows Vista, another was 64-bit Windows 10.

Who here can help me get these DLLs built? I need to learn how to do it myself so that I can build the DLLs as new GMP versions become available.
Prime95 is online now   Reply With Quote
Old 2017-08-28, 17:51   #2
GP2
 
GP2's Avatar
 
Sep 2003

5·11·47 Posts
Default

Perhaps you could try MPIR on Windows rather than GMP? It's a fork of GMP, which might be easier than GMP to compile and use on Windows.

It should work exactly the same way, in particular they both have a function:
int mpz_jacobi (mpz_t a, mpz_t b)

Last fiddled with by GP2 on 2017-08-28 at 17:52
GP2 is offline   Reply With Quote
Old 2017-08-28, 21:45   #3
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26·131 Posts
Default

https://stackoverflow.com/questions/...-64bit-windows might help ?
science_man_88 is offline   Reply With Quote
Old 2017-08-28, 22:27   #4
ATH
Einyen
 
ATH's Avatar
 
Dec 2003
Denmark

22·17·47 Posts
Default

I was about to write a guide on how I normally compile it in MSYS2, but I never compile a shared version only a static version. So I tested it just now and I can compile a shared version but it fails "make check".
I found this info:
https://gmplib.org/manual/Known-Build-Problems.html

Quote:
Compiler link options
The version of libtool currently in use rather aggressively strips compiler options when linking a shared library. This will hopefully be relaxed in the future, but for now if this is a problem the suggestion is to create a little script to hide them, and for instance configure with

./configure CC=gcc-with-my-options
Anyone know how to do this?
ATH is offline   Reply With Quote
Old 2017-08-28, 23:22   #5
ATH
Einyen
 
ATH's Avatar
 
Dec 2003
Denmark

22·17·47 Posts
Default

I managed to compile MPIR 3.0.0 shared version, so here is a guide for that:

Download the msys2-x86_64 package and install to the default c:\msys64: http://www.msys2.org/

Run:
pacman -Syu
(forcefully close MSYS2 when it informs you)

Edit the file: C:\msys64\etc\profile :
Change the line:
MSYS2_PATH="/usr/local/bin:/usr/bin:/bin"
to
MSYS2_PATH="/usr/local/bin:/usr/bin:/bin:/mingw64/bin"

(start MSYS2)
pacman -Su
(restart MSYS2)

install needed packages:

pacman -S mingw-w64-x86_64-gcc
pacman -S mingw-w64-x86_64-make
pacman -S mingw-w64-x86_64-libtool
pacman -S autoconf
pacman -S automake
pacman -S mingw-w64-x86_64-python3
pacman -S mingw-w64-x86_64-yasm
(only needed for MPIR, not for GMP 6.1.2)

Rename "C:\msys64\mingw64\bin\mingw32-make.exe" to "make.exe" in the same folder, or make a copy first and then rename.

MSYS2 has a preinstalled GMP version which does not seem easy to remove because other packages are dependent on it, so if it interferes you can move the files to another folder. This probably only happens if you need to compile other programs in MSYS2, that needs to use your own compiled GMP/MPIR version. The pre-installed GMP files are:
C:\msys64\mingw64\bin\libgmp-10.dll
C:\msys64\mingw64\bin\libgmpxx-4.dll
C:\msys64\mingw64\lib\libgmp.a
C:\msys64\mingw64\lib\libgmp.dll.a
C:\msys64\mingw64\lib\libgmpxx.a
C:\msys64\mingw64\lib\libgmpxx.dll.a
C:\msys64\mingw64\include\gmp.h
C:\msys64\mingw64\include\gmpxx.h


Download MPIR 3.0.0 http://mpir.org/downloads.html and compile:

./configure ABI=64 CC=gcc CFLAGS="-O3 -m64" --build=x86_64-w64-mingw32 --enable-gmpcompat --disable-static --enable-shared
make
make install
make check


The files are now here:
C:\msys64\usr\bin\libgmp-23.dll
C:\msys64\usr\bin\libmpir-23.dll
C:\msys64\usr\lib\libgmp.la
C:\msys64\usr\lib\libgmp.dll.a
C:\msys64\usr\lib\libmpir.la
C:\msys64\usr\lib\libmpir.dll.a
C:\msys64\usr\include\gmp.h
C:\msys64\usr\include\mpir.h

If you remove the --enable-gmpcompat from the configure line you only get the mpir versions of the files.

Last fiddled with by ATH on 2017-08-28 at 23:30
ATH is offline   Reply With Quote
Old 2017-08-28, 23:38   #6
Prime95
P90 years forever!
 
Prime95's Avatar
 
Aug 2002
Yeehaw, FL

2·11·349 Posts
Default

Thanks for the help.

I did finally succeed, kinda, in building a 32-bit DLL of GMP using Mingw-w64 and MSYS2.

I needed to do this:
pacman -S mingw-w64-i686-gcc
instead of:
pacman -S gcc

Like ATH, 'make check' fails. But my baby test program succeeds after renaming libgmp-10.dll to libgmp-3.dll.dll.



I have not looked at mpir yet. I cannot compile it with MSVC as I'm using MSVC 2005. Last I checked, the free MSVC versions would not build 64-bit binaries.
Prime95 is online now   Reply With Quote
Old 2017-08-28, 23:42   #7
Mysticial
 
Mysticial's Avatar
 
Sep 2016

15816 Posts
Default

Quote:
Originally Posted by Prime95 View Post
Thanks for the help.

I did finally succeed, kinda, in building a 32-bit DLL of GMP using Mingw-w64 and MSYS2.

I needed to do this:
pacman -S mingw-w64-i686-gcc
instead of:
pacman -S gcc

Like ATH, 'make check' fails. But my baby test program succeeds after renaming libgmp-10.dll to libgmp-3.dll.dll.



I have not looked at mpir yet. I cannot compile it with MSVC as I'm using MSVC 2005. Last I checked, the free MSVC versions would not build 64-bit binaries.
Visual Studio 2015 and 2017 Community edition are free. And they have pretty much everything - including the 64-bit compiler.
Mysticial is offline   Reply With Quote
Old 2017-08-28, 23:42   #8
ATH
Einyen
 
ATH's Avatar
 
Dec 2003
Denmark

22×17×47 Posts
Default

Do you trust it when "make check" fails? If you do here is how I compiled the 64-bit version of GMP 6.1.2:

./configure ABI=64 CC=gcc CFLAGS="-O3 -m64" --build=x86_64-w64-mingw32 --disable-static --enable-shared
make
make install
make check

Files are in C:\msys64\usr\bin, C:\msys64\usr\lib, C:\msys64\usr\include.

Last fiddled with by ATH on 2017-08-28 at 23:42
ATH is offline   Reply With Quote
Old 2017-08-28, 23:50   #9
ATH
Einyen
 
ATH's Avatar
 
Dec 2003
Denmark

22·17·47 Posts
Default

Quote:
Originally Posted by Prime95 View Post
I did finally succeed, kinda, in building a 32-bit DLL of GMP using Mingw-w64 and MSYS2.
Are you sure it is 32-bit if you used mingw-w64-i686-gcc ?

When I had to compile a 32-bit version a while ago, I installed the 32-bit version of MSYS2: msys2-i686-20161025.exe.
It installs to c:\msys32 so you can have that and the 64 bit version at the same time.

I used these commands and packages:

pacman -Syu
restart MSYS2
pacman -Su

pacman -S gcc
pacman -S make
pacman -S autoconf
pacman -S libtool
pacman -S automake

Last fiddled with by ATH on 2017-08-28 at 23:59
ATH is offline   Reply With Quote
Old 2017-08-29, 00:02   #10
Prime95
P90 years forever!
 
Prime95's Avatar
 
Aug 2002
Yeehaw, FL

11101111111102 Posts
Default

Quote:
Originally Posted by ATH View Post
Are you sure it is 32-bit if you used mingw-w64-i686-gcc ?
Yes. The OS is Windows Vista 32-bit.

As to trusting the DLL when I cannot build 'make check' --- no, I do not trust the DLL. Trying mpir compile now...
Prime95 is online now   Reply With Quote
Old 2017-08-29, 01:38   #11
Prime95
P90 years forever!
 
Prime95's Avatar
 
Aug 2002
Yeehaw, FL

2×11×349 Posts
Default

MPIR compiles quite a bit cleaner. I've built a 32-bit DLL and run 'make check' successfully.

Two gotchas so far. The Makefile fails if the path contain blanks as in
--prefix=/home/'George Woltman'/mpir-3.0.0
Building the .lib file for the DLL requires renaming the libmpir-3.dll.def file before executing the MSVC library manager.

Last fiddled with by Prime95 on 2017-08-29 at 01:50
Prime95 is online now   Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Building sr1sieve for RPi wombatman Software 14 2017-03-04 16:21
Building MSieve without VS? SWSaunders Msieve 3 2013-04-26 11:19
Help building new computer Prime95 Hardware 30 2009-09-12 05:58
Building gcc 4.4.0 CRGreathouse Software 1 2009-07-07 22:25
Building on Linux? FenwayFrank Software 4 2002-10-20 21:59

All times are UTC. The time now is 22:43.


Wed Dec 1 22:43:19 UTC 2021 up 131 days, 17:12, 1 user, load averages: 1.11, 1.20, 1.30

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

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.