Hello. I am using MS Visual Studio 2017, CMake for building wxWidgets from source and for making project using it. I am building a fully static wxWidgets aimed to compile inside a project with /MT or /MTd key. Here is my CMAKE setup:
The first thing is: when I compile BUILD_ALL project, I have to set up /MT key for wxexpat, wxjpeg, wxpng and wxregex projects, because compiling halts and I cannot get the wxbase lib file. But setting keys gets things done, wxWidgets compiles without errors and warnings.
Problems start when I try to compile project . I add wxmsw31u_core.lib;wxbase31u.lib lib files, as mentioned in tutorial, but I get then the following errors upon linking:
(one of them is Error LNK2001 unresolved external symbol _wx_png_create_info_struct wxmsw31u_core.lib(imagpng.obj) )
Another one is
Severity Code Description Project File Line Suppression State
Error LNK2001 unresolved external symbol __imp__CreateUpDownControl@48 ProjectSendSignal C:\SOME_NAME\OTHERCODE\SendSignal\SendSignal\ProjectSendSignal\wxmsw31u_core.lib(spinbutt.obj) 1
How do I make it compile? This project compiled with wxWidgets 3.0.1 /MD
compiling project with /MT key - weird references to _wx_png and other upon linking
Re: compiling project with /MT key - weird references to _wx_png and other upon linking
I can confirm the issue. The 3rd party libraries which are GIT submodules do not have the Runtime library set to static when wxBUILD_USE_STATIC_RUNTIME is checked. I believe it is a bug and you should report it on wxTrac (or fix it and provide a PR).
As for the linker errors, assuming there is no CRT mismatch, it looks as if the libraries (wxpng, comctl32, rpcrt4) were not added to linker in your project?
As for the linker errors, assuming there is no CRT mismatch, it looks as if the libraries (wxpng, comctl32, rpcrt4) were not added to linker in your project?
Re: compiling project with /MT key - weird references to _wx_png and other upon linking
Hi,
Is it an "experimental CMake" problem?
Can you build the libraries with the official wx solution out of the box?
Thank you.
Is it an "experimental CMake" problem?
Can you build the libraries with the official wx solution out of the box?
Thank you.
Re: compiling project with /MT key - weird references to _wx_png and other upon linking
I have managed to compile my wxWidgets project. It is important that compiling of wxWidgets compiles fine, without errors. So all libraries (.lib) are built. My setup of lib files is the following:
wxmsw31ud_core.lib
wxbase31ud.lib
wxpngd.lib
wxzlibd.lib
kernel32.lib
user32.lib
gdi32.lib
winspool.lib
comdlg32.lib
advapi32.lib
shell32.lib
ole32.lib
oleaut32.lib
uuid.lib
odbc32.lib
odbccp32.lib
comctl32.lib
rpcrt4.lib
It works but is wrong that core libraries depend on png ( and zlib is required by png) library. My program does not use png explicitly.
wxmsw31ud_core.lib
wxbase31ud.lib
wxpngd.lib
wxzlibd.lib
kernel32.lib
user32.lib
gdi32.lib
winspool.lib
comdlg32.lib
advapi32.lib
shell32.lib
ole32.lib
oleaut32.lib
uuid.lib
odbc32.lib
odbccp32.lib
comctl32.lib
rpcrt4.lib
It works but is wrong that core libraries depend on png ( and zlib is required by png) library. My program does not use png explicitly.
Re: compiling project with /MT key - weird references to _wx_png and other upon linking
By the way, if you are using MSVC, adding libraries by hand is not necessary. It may be better to rely on wxWidgets autolinking feature available for MSVC, either by prepending $(WXWIN)\include\msvc to the compiler include paths or using a provided MSVS property sheet. And there's also VCPKG...
I will submit a ticket regarding the CRT linkage. I am not sure about the libpng dependency, will look into it. But I think it comes from the ability of wxBitmap and wxImage to use the format. However, if this were the case, why is not libtiff needed as well?
I will submit a ticket regarding the CRT linkage. I am not sure about the libpng dependency, will look into it. But I think it comes from the ability of wxBitmap and wxImage to use the format. However, if this were the case, why is not libtiff needed as well?
Re: compiling project with /MT key - weird references to _wx_png and other upon linking
The static CRT linking issue has actually already been fixed in the master
https://github.com/wxWidgets/wxWidgets/ ... 0a0da7bbbd
https://github.com/wxWidgets/wxWidgets/ ... 0a0da7bbbd