wxMSW-3.1.3_gcc810_Dev can not static link?

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
kankouhin
In need of some credit
In need of some credit
Posts: 1
Joined: Wed Feb 05, 2020 3:09 am

wxMSW-3.1.3_gcc810_Dev can not static link?

Post by kankouhin » Wed Feb 05, 2020 3:17 am

create a wx sample and compile with:

mingw64bit can static link any library to exe, but with mingw32bit, it seems can not static link the librarys, after compiled ,the exe alse need
dll files within same folder. ex. wxbase313u_gcc810.dll, wxmsw313u_core_gcc810.dll and libgcc_s_sjlj-1.dll

How to static link librarys with mingw32bit?

Code: Select all

g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DwxUSE_UNICODE -Wall -O2 -IC:\wxWidgets-3.1.3\include -IC:\wxWidgets-3.1.3\lib\gcc810_x64_dll\mswu -c C:\wx\wxApp.cpp -o obj\Release\wxApp.o
g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DwxUSE_UNICODE -Wall -O2 -IC:\wxWidgets-3.1.3\include -IC:\wxWidgets-3.1.3\lib\gcc810_x64_dll\mswu -c C:\wx\wxMain.cpp -o obj\Release\wxMain.o
g++.exe -LC:\wxWidgets-3.1.3\lib\gcc810_x64_dll -o bin\wx.exe  obj\Release\wxApp.o obj\Release\wxMain.o obj\Release\resource.res -s -static-libstdc++ -static-libgcc -static -mthreads  -lwxmsw31u_core -lwxbase31u -lwxpng -lwxzlib -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lcomctl32 -lwsock32 -lodbc32 -lshlwapi -lversion -mwindows
Last edited by catalin on Wed Feb 05, 2020 6:52 am, edited 1 time in total.
Reason: code tags

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2245
Joined: Sun Jan 03, 2010 5:45 pm

Re: wxMSW-3.1.3_gcc810_Dev can not static link?

Post by PB » Wed Feb 05, 2020 7:18 am

Based on wxWidgets library folder name, you are linking the DLLs:
C:\wxWidgets-3.1.3\lib\gcc810_x64_dll\mswu

The static build should be in:
C:\wxWidgets-3.1.3\lib\gcc810_x64_lib\mswu
That assumes you are building wxWidgets by yourself, the wxWidgets pre-built binaries are dynamic linking only.

Obviously, if you do not want to depend on any DLLs, both wxWidgets and your program need to link to the compiler runtime libraries (CRT...) statically, e.g. wxWidgets are built with

Code: Select all

mingw32-make -f makefile.gcc BUILD=release  CXXFLAGS="-std=c++17 -static"

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 3915
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxMSW-3.1.3_gcc810_Dev can not static link?

Post by ONEEYEMAN » Wed Feb 05, 2020 2:38 pm

Hi,
To the OP - you should compile wxWidgets without "SHARED" option.
And of course use the same toolchain for both library and your own application.

Thank you.

Post Reply