[SOLVED] Re: setting CPU_TYPE when cross-compiling from Linux to Windows

Claude Heiland-Allen claude at mathr.co.uk
Fri Jan 3 12:30:34 UTC 2020


On 03/01/2020 12:15, Niels Möller wrote:
> Claude Heiland-Allen <claude at mathr.co.uk> writes:
>> Aha, thanks for this tip, I found an incantation that works:
>> ```
>> CC=x86_64-w64-mingw32-gcc \
>> CC_FOR_BUILD=x86_64-linux-gnu-gcc \
>> LDFLAGS="-static-libgcc -static-libstdc++" \
>> ./configure \
>>    --build=x86_64-linux-gnu \
>>    --host=x86_64-w64-mingw32 \
>>    --enable-fat \
>>    --enable-static \
>>    --disable-shared \
>>    --prefix=/home/claude/wintmp/
>> ```
>> The `CPPFLAGS` is necessary to avoid test failure in printf/scanf.
> That's a known problem, maybe it should somehow be enabled by default by
> gmp's configure, but I don't fully understand the implications.
> Not sure why the setting of LDFLAGS and CC_FOR_BUILD are needed though,
> can you explain?

LDFLAGS is just personal preference so I can ship my final program 
without DLL dependencies, I don't know if it is necessary or even has 
any effect for static .a libraries.

CC_FOR_BUILD is necessary otherwise the configure fails because it uses 
the wrong build system compiler:

$ CC=x86_64-w64-mingw32-gcc  CPPFLAGS=-D__USE_MINGW_ANSI_STDIO 
LDFLAGS="-static-libgcc -static-libstdc++" ./configure 
--build=x86_64-linux-gnu --host=x86_64-w64-mingw32 --enable-fat 
--enable-static --disable-shared --prefix=/home/claude/wintmp/
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-w64-mingw32
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for x86_64-w64-mingw32-strip... x86_64-w64-mingw32-strip
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether to enable maintainer-specific portions of Makefiles... no
checking ABI=64
checking whether x86_64-w64-mingw32-gcc is gcc... yes
checking compiler x86_64-w64-mingw32-gcc -O2 -pedantic 
-fomit-frame-pointer -m64 -D__USE_MINGW_ANSI_STDIO... yes
checking compiler x86_64-w64-mingw32-gcc -O2 -pedantic 
-fomit-frame-pointer -m64 -D__USE_MINGW_ANSI_STDIO has long long... yes
checking for x86_64-w64-mingw32-gcc... x86_64-w64-mingw32-gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.exe
checking for suffix of executables... .exe
checking whether we are cross compiling... yes
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether x86_64-w64-mingw32-gcc accepts -g... yes
checking for x86_64-w64-mingw32-gcc option to accept ISO C89... none needed
checking whether x86_64-w64-mingw32-gcc understands -c and -o 
together... yes
checking for x86_64-w64-mingw32-gcc option to accept ISO C99... none needed
checking how to run the C preprocessor... x86_64-w64-mingw32-gcc -E
checking build system compiler x86_64-w64-mingw32-gcc... yes
checking for build system preprocessor... x86_64-w64-mingw32-gcc -E
checking for build system executable suffix... configure: error: Cannot 
determine executable suffix


More information about the gmp-bugs mailing list