![]() |
|
|
#1 |
|
Jul 2021
3310 Posts |
Can anyone suggest steps how to compile GMP for Windows? I need to use it under MSVC. Also I need it as a static library without any DLL dependencies.
Some people post instructions how to build it using Cygwin. But Cygwin always dynamically links Cygwin's system dlls. And I need fully static solution, so that my final EXE has no DLL deps. Also I'm not very sure if Cygwin version of GMP will be friendly to use in MSVC. Maybe MSYS has ability to build such dependencies free static library? Does anyone know how can I use such msys-generated library in MSVC without problems? Also I'm aware that there exists MPIR library, which should be more Windows-friendly. But right now I need specifically GMP solution. Also if possible to build GMP for MSVC usage then of course would be preferrable to do all optimizations including all assembly code. If not possible to use assembly in Windows then if someone can suggest steps how to compile for MSVC but without assembly? I'm alright with building GMP not in MSVC, but in Cygwin or MSYS as far as it can be used later in MSVC without any problems. And as I told only statical solution is acceptable for me, without any DLL dependencies. |
|
|
|
|
|
#2 |
|
P90 years forever!
Aug 2002
Yeehaw, FL
17×487 Posts |
I think you are stuck with MSYS (if you get MSVC to build it, do post instructions on how to do it!).
Here are my many-years-old build notes for building on MSYS. Note the use of MSVC library tools. If you flip the disable-static and enable-shared options maybe these instructions will serve your needs. Code:
Building libgmp-10.dll (rename this DLL to something unique. Ordinals can change with each source change. DLL hell) ---------------------- Install msys2 from msys2.org (see http://repo.msys2.org/distrib/i686/ for the October 2016 installer) pacman -Syuu (exit and repeat) pacman -S tar pacman -S gcc (not needed?) pacman -S m4 pacman -S make pacman -S diffutils pacman -S libtool pacman -S mingw-w64-i686-gcc pacman -S mingw-w64-x86_64-gcc download gmp sources (the .bz2 file, not the .lz file) Close the MSYS shell Launch mingw32 shell: tar xvf gmp sources ./configure --prefix=/home/gmp_dir --enable-fat --disable-static --enable-shared (note: may be best if gmpdir does not contain any spaces, though I got away with single-quoting) make make check From Windows shell: run vcvars (see c.bat) cd .libs rename libgmp-10.dll libgmp-gw1.dll rename libgmp-3.dll.def libgmp-gw1.def lib /def:libgmp-gw1.def /out:libgmp-gw1.lib Launch mingw64 shell: (built on 64-bit Windows machine!) tar xvf gmp sources ./configure --prefix=/home/gmp_dir64 --enable-fat --disable-static --enable-shared make make check From Windows shell: run vcvars (see c64.bat) cd .libs rename libgmp-10.dll libgmp-gw1.dll rename libgmp-3.dll.def libgmp-gw1.def lib /def:libgmp-gw1.def /out:libgmp-gw1.lib /MACHINE:X64 |
|
|
|
|
|
#3 | |
|
Jul 2021
3×11 Posts |
Quote:
I used .a prebuilt libraries taken from MSYS distribution. Besides regular process of compiling through MSVC, I did extra following things: 1) Installed GMP in MSYS through "pacman -S mingw-w64-clang-x86_64-gmp" 2) Added to MSVC include search path (/I option) directory - d:/bin2/msys64/clang64/include/ 3) To msvc linker gave 4 libraries (following paths start from d:/bin2/msys64/ folder where MSYS is located): clang64/lib/libgmp.a clang64/lib/libgmpxx.a mingw64/lib/gcc/x86_64-w64-mingw32/10.3.0/libgcc.a clang64/x86_64-w64-mingw32/lib/libmingwex.a 4) Also I had to add /FORCE option to linker because there were two duplicate symbols between MSYS and MSVC default libraries. This force flag forces linker to ignore duplicate and unresolved symbols. All above uses static .a libraries, so my final EXE had no external DLL in dependencies (except Windows system DLLs). After that program ran successfully without errors and at full expected speed. So feeding .a libraries from MSYS to MSVC works quite well. Also separately I easily compiled MSYS version of static .a libraries of most recent GMP sources through - "./configure && make -j8". But didn't use this version because default prebuilt MSYS GMP version is quite recent and works well. Last fiddled with by moytrage on 2021-09-18 at 17:47 |
|
|
|
|
|
|
#4 |
|
Bamboozled!
"๐บ๐๐ท๐ท๐ญ"
May 2003
Down not across
2·17·347 Posts |
Can you explain why you need GMP and why MPIR is unsuitable? I know people in the MPIR community and they may be able to help remedy any deficiency MPIR might have.
|
|
|
|
|
|
#5 |
|
Jul 2021
3×11 Posts |
MPIR is unsuitable for quite minor reasons, because GMP was chosen for our project as a main backend, because our people don't want extra other libraries dependencies, also because it is nice if we use single library everywhere on all OSes.
But first of all I just wanted to check if GMP can be ported to Windows, it will be very great. Of course if it can't then definitely we will use MPIR. Also from my last post above you can see that I successfully managed to use GMP on MSVC/Windows. But solution is not that clean as it would be if everything was compiled by MSVC only. But still quite acceptable. So GMP with all optimizations in fact can be used on MSVC/Windows. Can you tell me in short does MPIR have identical interface as GMP? Meaning if we have huge code written and tested for GMP can we just replace GMP with MPIR and code will be compilable and working? |
|
|
|
|
|
#6 | |
|
"Alexander"
Nov 2008
The Alamo City
99110 Posts |
Quote:
Last fiddled with by Happy5214 on 2021-09-21 at 11:39 Reason: Add emphasis |
|
|
|
|
|
|
#7 |
|
"Ben"
Feb 2007
3×5×251 Posts |
I believe that is it's goal - it was originally forked from GMP. I have been happily using it for years as a drop-in compatible library with GMP for MSVC builds in several projects. But my projects are not all that big and don't touch many corners of the library.
|
|
|
|
|
|
#8 |
|
Sep 2016
22·5·19 Posts |
Worth noting that there's quite a bit of beef between GMP and MPIR.
The GMP devs hate Windows and anything Microsoft. It's quite obvious from the tone of language in their mailing lists. This hostility towards Windows is why MPIR was made. So then the GMP devs started hating on MPIR probably because it became a competitor. |
|
|
|
|
|
#9 | |
|
If I May
"Chris Halsall"
Sep 2002
Barbados
2×112×47 Posts |
Quote:
My own opinion... Their software has been shit for years. They used market manipulation to become dominant just when the critical decisions were being made. I will never forget when my boss (the CTO) at a Canadian Hospital was tricked into believing the warning messages trying to install Windows 3.0 onto a competitive DOS offering. He "drank the Kool-Aid" and made a bad decision. I resigned shortly later. Fast forward to Today, and Microsoft has embraced Open Source. Mostly because of "Cloud Compute". Suddenly it's no longer a "cancer". P.S. Just for the record, M$ *did* lose an AntiTrust case. Which was then reversed by a certain Bush. |
|
|
|
|
![]() |
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| build with MSVC 2010 problem | Geek2600 | Msieve | 0 | 2018-02-12 13:37 |
| PFGW build help (with MSVC 2012 Express) | Prime95 | Software | 5 | 2013-08-07 23:51 |
| Is it worth the trouble to "upgrade" Windows 8 to Windows 7? | ixfd64 | Lounge | 23 | 2013-04-13 11:12 |
| Windows 7 Windows Update & Prime95 issue!!! | Unregistered | Information & Answers | 14 | 2010-04-10 21:47 |
| Compiling GMP-ECM in Windows using MSVC | jbristow | GMP-ECM | 4 | 2008-04-17 14:42 |