How to cross compile from Linux for Windows

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
kagi3624
Knows some wx things
Knows some wx things
Posts: 29
Joined: Wed Feb 26, 2020 8:13 am

How to cross compile from Linux for Windows

Post by kagi3624 »

Hello, I created a build for windows without shared libraries. Now when I try to compile the samples with the provided make file I get an exe. But it does not run on windows because some libgcc_s_seh-1.dll is missing. So how can I compile those samples via the terminal command line or how should I modify the make files so those exe files run on windows? Thank you very much!
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4193
Joined: Sun Jan 03, 2010 5:45 pm

Re: How to cross compile from Linux for Windows

Post by PB »

As you did not provide any concrete information about your build, I assume you just built wxWidgets statically, with SHARED=0 or omitting SHARED parameter at all.

But you still need the compiler DLLs. So either you copy the DLL to the same folder your application executable is or build wxWidgets and the application to link to the compiler libraries statically as well.

I do not know how to do it on Linux, but on MSW with GCC makefile, you would pass the linker flags to GCC with

Code: Select all

LDFLAGS="-static"
for example like this

Code: Select all

mingw32-make -f makefile.gcc SHARED=0 CXXFLAGS="-std=c++17" LDFLAGS="-static"
EDIT
It seems you already dealt with this before?
viewtopic.php?f=19&t=46893&start=15#p197234
kagi3624
Knows some wx things
Knows some wx things
Posts: 29
Joined: Wed Feb 26, 2020 8:13 am

Re: How to cross compile from Linux for Windows

Post by kagi3624 »

It seems you already dealt with this before?
Yeah, I put the missing libs next to the CXXFLAGS in ine makefile, but it does not seem to work anymore.

Edit. I just combined the first answer with the libs like that

Code: Select all

x86_64-w64-mingw32-g++ *.cpp -o out.exe `PATH/TO/wxIDGETS/build_win/wx-config --cxxflags` `PATH/TO/wxIDGETS/build_win/wx-config --libs` -static-libgcc -static-libstdc++
and it worked. The part with the

Code: Select all

$(wx-config --cxxflags --libs)
does not work for some reason. But I am not an expert in consoles and linux :oops:
Post Reply