简体   繁体   中英

Compiling GMP Library with Mingw on Linux

I try to compile my written C++ code G++ GMP on Windows. My program works fine on Ubuntu. I need to recompile and build the library with Mingw-G++ to eventually compile my final program with Mingw for Windows.

My problem now:

The configure file provided with the library does not look like it can set Mingw-GCC over GCC as compiler anywhere. You can set flags for build and host type but they don't bring the desired results (in my testing). Im far from being an expert with makefiles and shell scripts, so it might seem like I can't set the compiler, but I think I just overlook something. I can imagine that i need so set the path to Mingw in the configure file myself, but i dont want to break anything YET .

I figured out that there is a CClist in the configure file, which is set to gcc / gcc icc etc... it determines which list of compilers to set depending on the CPU build type (arm/amd64/etc...).<

Another problem: the mingw gcc compiler on linux isn't named gcc unlike on windows but rather x86_64-w64-mingw32-gcc ...so the script can't detect it as gcc

Thanks in advance

Edit

After some help from @SuperStormer i set the compiler as mingw32-gcc correctly as my config.status file show, however make check fails with the following warnings:

z.lo spinner.lo trace.lo  ../libgmp.la 
libtool: warning: '-no-install' is ignored for x86_64-w64-mingw32
libtool: warning: assuming '-no-fast-install' instead
libtool: link: x86_64-w64-mingw32-ar cq .libs/libtests.a  memory.o misc.o refmpf.o refmpn.o refmpq.o refmpz.o spinner.o trace.o
libtool: link: x86_64-w64-mingw32-ranlib .libs/libtests.a
libtool: link: ( cd ".libs" && rm -f "libtests.la" && ln -s "../libtests.la" "libtests.la" )
x86_64-w64-mingw32-gcc -DHAVE_CONFIG_H -I. -I..  -I..   -O2 -pedantic -fomit-frame-pointer -m64 -mtune=k8 -march=k8 -c -o t-bswap.o t-bswap.c
/bin/bash ../libtool  --tag=CC   --mode=link x86_64-w64-mingw32-gcc  -O2 -pedantic -fomit-frame-pointer -m64 -mtune=k8 -march=k8 -no-install  -o t-bswap.exe t-bswap.o libtests.la ../libgmp.la 
libtool: warning: '-no-install' is ignored for x86_64-w64-mingw32
libtool: warning: assuming '-no-fast-install' instead
libtool: link: x86_64-w64-mingw32-gcc -O2 -pedantic -fomit-frame-pointer -m64 -mtune=k8 -march=k8 -o t-bswap.exe t-bswap.o  ./.libs/libtests.a /home/me/Downloads/gmp-6.2.1/.libs/libgmp.a ../.libs/libgmp.a
x86_64-w64-mingw32-gcc -DHAVE_CONFIG_H -I. -I..  -I..   -O2 -pedantic -fomit-frame-pointer -m64 -mtune=k8 -march=k8 -c -o t-constants.o t-constants.c
/bin/bash ../libtool  --tag=CC   --mode=link x86_64-w64-mingw32-gcc  -O2 -pedantic -fomit-frame-pointer -m64 -mtune=k8 -march=k8 -no-install  -o t-constants.exe t-constants.o libtests.la ../libgmp.la 
libtool: warning: '-no-install' is ignored for x86_64-w64-mingw32
libtool: warning: assuming '-no-fast-install' instead
libtool: link: x86_64-w64-mingw32-gcc -O2 -pedantic -fomit-frame-pointer -m64 -mtune=k8 -march=k8 -o t-constants.exe t-constants.o  ./.libs/libtests.a /home/me/Downloads/gmp-6.2.1/.libs/libgmp.a ../.libs/libgmp.a
x86_64-w64-mingw32-gcc -DHAVE_CONFIG_H -I. -I..  -I..   -O2 -pedantic -fomit-frame-pointer -m64 -mtune=k8 -march=k8 -c -o t-count_zeros.o t-count_zeros.c
/bin/bash ../libtool  --tag=CC   --mode=link x86_64-w64-mingw32-gcc  -O2 -pedantic -fomit-frame-pointer -m64 -mtune=k8 -march=k8 -no-install  -o t-count_zeros.exe t-count_zeros.o libtests.la ../libgmp.la 
libtool: warning: '-no-install' is ignored for x86_64-w64-mingw32
libtool: warning: assuming '-no-fast-install' instead
libtool: link: x86_64-w64-mingw32-gcc -O2 -pedantic -fomit-frame-pointer -m64 -mtune=k8 -march=k8 -o t-count_zeros.exe t-count_zeros.o  ./.libs/libtests.a /home/me/Downloads/gmp-6.2.1/.libs/libgmp.a ../.libs/libgmp.a
x86_64-w64-mingw32-gcc -DHAVE_CONFIG_H -I. -I..  -I..   -O2 -pedantic -fomit-frame-pointer -m64 -mtune=k8 -march=k8 -c -o t-hightomask.o t-hightomask.c
/bin/bash ../libtool  --tag=CC   --mode=link x86_64-w64-mingw32-gcc  -O2 -pedantic -fomit-frame-pointer -m64 -mtune=k8 -march=k8 -no-install  -o t-hightomask.exe t-hightomask.o libtests.la ../libgmp.la 
libtool: warning: '-no-install' is ignored for x86_64-w64-mingw32
libtool: warning: assuming '-no-fast-install' instead
libtool: link: x86_64-w64-mingw32-gcc -O2 -pedantic -fomit-frame-pointer -m64 -mtune=k8 -march=k8 -o t-hightomask.exe t-hightomask.o  ./.libs/libtests.a /home/me/Downloads/gmp-6.2.1/.libs/libgmp.a ../.libs/libgmp.a
x86_64-w64-mingw32-gcc -DHAVE_CONFIG_H -I. -I..  -I..   -O2 -pedantic -fomit-frame-pointer -m64 -mtune=k8 -march=k8 -c -o t-modlinv.o t-modlinv.c
/bin/bash ../libtool  --tag=CC   --mode=link x86_64-w64-mingw32-gcc  -O2 -pedantic -fomit-frame-pointer -m64 -mtune=k8 -march=k8 -no-install  -o t-modlinv.exe t-modlinv.o libtests.la ../libgmp.la 
libtool: warning: '-no-install' is ignored for x86_64-w64-mingw32
libtool: warning: assuming '-no-fast-install' instead
libtool: link: x86_64-w64-mingw32-gcc -O2 -pedantic -fomit-frame-pointer -m64 -mtune=k8 -march=k8 -o t-modlinv.exe t-modlinv.o  ./.libs/libtests.a /home/me/Downloads/gmp-6.2.1/.libs/libgmp.a ../.libs/libgmp.a
x86_64-w64-mingw32-gcc -DHAVE_CONFIG_H -I. -I..  -I..   -O2 -pedantic -fomit-frame-pointer -m64 -mtune=k8 -march=k8 -c -o t-popc.o t-popc.c
/bin/bash ../libtool  --tag=CC   --mode=link x86_64-w64-mingw32-gcc  -O2 -pedantic -fomit-frame-pointer -m64 -mtune=k8 -march=k8 -no-install  -o t-popc.exe t-popc.o libtests.la ../libgmp.la 
libtool: warning: '-no-install' is ignored for x86_64-w64-mingw32
libtool: warning: assuming '-no-fast-install' instead
libtool: link: x86_64-w64-mingw32-gcc -O2 -pedantic -fomit-frame-pointer -m64 -mtune=k8 -march=k8 -o t-popc.exe t-popc.o  ./.libs/libtests.a /home/me/Downloads/gmp-6.2.1/.libs/libgmp.a ../.libs/libgmp.a
x86_64-w64-mingw32-gcc -DHAVE_CONFIG_H -I. -I..  -I..   -O2 -pedantic -fomit-frame-pointer -m64 -mtune=k8 -march=k8 -c -o t-parity.o t-parity.c
/bin/bash ../libtool  --tag=CC   --mode=link x86_64-w64-mingw32-gcc  -O2 -pedantic -fomit-frame-pointer -m64 -mtune=k8 -march=k8 -no-install  -o t-parity.exe t-parity.o libtests.la ../libgmp.la 
libtool: warning: '-no-install' is ignored for x86_64-w64-mingw32
libtool: warning: assuming '-no-fast-install' instead
libtool: link: x86_64-w64-mingw32-gcc -O2 -pedantic -fomit-frame-pointer -m64 -mtune=k8 -march=k8 -o t-parity.exe t-parity.o  ./.libs/libtests.a /home/me/Downloads/gmp-6.2.1/.libs/libgmp.a ../.libs/libgmp.a
x86_64-w64-mingw32-gcc -DHAVE_CONFIG_H -I. -I..  -I..   -O2 -pedantic -fomit-frame-pointer -m64 -mtune=k8 -march=k8 -c -o t-sub.o t-sub.c
/bin/bash ../libtool  --tag=CC   --mode=link x86_64-w64-mingw32-gcc  -O2 -pedantic -fomit-frame-pointer -m64 -mtune=k8 -march=k8 -no-install  -o t-sub.exe t-sub.o libtests.la ../libgmp.la 
libtool: warning: '-no-install' is ignored for x86_64-w64-mingw32
libtool: warning: assuming '-no-fast-install' instead
libtool: link: x86_64-w64-mingw32-gcc -O2 -pedantic -fomit-frame-pointer -m64 -mtune=k8 -march=k8 -o t-sub.exe t-sub.o  ./.libs/libtests.a /home/me/Downloads/gmp-6.2.1/.libs/libgmp.a ../.libs/libgmp.a
make[4]: Verzeichnis „/home/me/Downloads/gmp-6.2.1/tests“ wird verlassen

and this

FAIL: t-bswap.exe
FAIL: t-constants.exe
FAIL: t-count_zeros.exe
FAIL: t-hightomask.exe
FAIL: t-modlinv.exe
FAIL: t-popc.exe
FAIL: t-parity.exe
FAIL: t-sub.exe
============================================================================
Testsuite summary for GNU MP 6.2.1
============================================================================
# TOTAL: 8
# PASS:  0
# SKIP:  0
# XFAIL: 0
# FAIL:  8
# XPASS: 0
# ERROR: 0
============================================================================
See tests/test-suite.log

Test-suite-log says: it can't run the.exe file. It's clear to me why it can't, but is there any workaround to create a linux excutable instead? Or is make check expected to fail?

Solution

Quick guess is that make check can't succeed on linux with mingw. I ran make install, and my program now runs fine (regarding my library issues)

This answer is mostly based on this mailing list post .

Commands ran:

export CC=x86_64-w64-mingw32-gcc
export CC_FOR_BUILD=x86_64-linux-gnu-gcc
./configure --build=x86_64-linux-gnu --host=x86_64-w64-mingw32 --enable-cxx
make

Tweak this however you want.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM