wxWidgets LNK1104 error when linking Statically in MVS and c++

89 Views Asked by At

wxWidgets LNK1104 error when linking Statically

Hello everyone, I am trying to link wxWidgets 3.2.2.1 to my project. it works with no problem when I build it with MDd/MD (shared library) and link against vc_lib directory . In this project though, I need it to use Mtd/Mt (Static library) but i keep getting this error:

Error LNK1104 cannot open file 'wxbase31u.lib' PDFiumWxWidget D:....\LINK 11

The library is built by myself as a static version using MSv 2019 by selecting all the Projects in the wx_vc17.sln and changing the setting in Code generation to Mtd for debug Mode and Mt for release Mode. Then I Batch built all.

I already have the generated vc_lib directory as a search directory for the linker. Also tried adding all generated .lib files as input, that didn't help either.

Project setting are as follow: on windows 10 , MVS 2019, x86 project, Release, Use Mt ,Use c++ 17 .

Searching the Wxwidgets library i can't find a file called 'wxbase31u.lib' at all.

I'd really appreciate if someone could point to some hints Thanks in advance.

2

There are 2 best solutions below

0
VZ. On BEST ANSWER

You're not supposed to be linking with wxbase31u.lib when using wxWidgets 3.2, this is the name of wxWidgets 3.1 library. You don't say where does this library name come from, but grepping your sources/projects for it should find it and you probably just need to replace the name with the correct/up to date one.

To avoid such problems in the future, I strongly advise to use wxwidgets.props as explained in the docs, then you'd always link with the correct library automatically.

0
Alex Müller On

Thanks for all that gave an answer, there was two problems, firstly what VZ. said, secondly was the order of the included directories. They must be in this order, otherwise one might get errors:

$(WXWIN)\include\msvc;$(WXWIN)\include