0

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.

  • how did you build wxWidgets? All you had to do is grab the sources, unpack it, open appropriate solution and batch-build it. No changes required. – Igor Mar 12 '23 at 14:06
  • Hey Igor, the no changes way is only in the case, if one wants to get a MD/MDD build. In my case I require a MT/MTD static build as I am using two libraries in the project, and the second library is Static. I followed the instructions of the static build in this guide: https://wiki.wxwidgets.org/Compiling_WxWidgets_with_MSVC_(2) I just managed to solve the mentioned error, which was apparently caused by the include order. Now I have 361 new errors. Did you ever do a MT/MTD build of wxWidget? I am not sure what is happening, as the same code with an MDD/MD build works flowlesly. – Alex Müller Mar 12 '23 at 17:11
  • what you do is open the solution, go to "Build -> Batch Build", click "Select All" and then click "Build". No need to change the default settings of the solution/projects. Or if you absolutely sure you need only one configuration, you select the appropriate checkboxes in the Batch Build dialog. But building everything is easier - 2 clicks vs many. I'm also not sure what is happenning in your case. Try to build wxWidgets as I suggested. Also - WiKi shouldn't be the source of the info as its almost always either outdated or doesn't make much sense – Igor Mar 12 '23 at 17:29
  • Thanks for the answer Igor, when I do that, without changing settings to Mt/Mtd , if I only link wxWidgets to a project it works fine, but when I try using it with another library in the same project, where the other library must stay static, then i get a runtime mismatch between the two libraries, as one is trying to run with Mt and the other is trying to run with Md. So I know it runs if I just open the library and batch build it without changing anything, you are right about that, but The problem here is the need for it to use the Mt runtime library. – Alex Müller Mar 12 '23 at 17:58
  • is the other library using wxWidgets? If I undertand you correctly - it does and it links statically to wx. If that is the case - are you using pre-buiuld binary for it, or you build it yourself? Is the library closed source? Keep that Batch Build you just did and lets fix the outstanding issue you are having... – Igor Mar 12 '23 at 18:14
  • The other library is PDFium, it is open source and if i understand correctly it uses Mt/Mtd. I did build it myself and it functions with no errors when i run it in a project separately. I am trying to build an app that can process, edit and pull info from pdf files, and I wanted to make a GUI for it using wxwidgets, so I linked both libraries to the project where I am developing the app. – Alex Müller Mar 12 '23 at 18:20
  • what f you buld everything dynamically? You have control on how you build wxWidgets and PDFLum, so... – Igor Mar 12 '23 at 19:46
  • Actually that would be the prefered workflow, but the dynamic PDFium build didn't produce the pdfium.dll and didn't give any errors either so I couldn't troubleshoot the problem. The documentation of PDFium also don't provide any info about building dynamically and the bug reports there is possibly outdated as I tried what they wrote there and it didn't work. I will start a new question regarding the subject as it is now out of the scope of this one. – Alex Müller Mar 13 '23 at 09:04

2 Answers2

1

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

0

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.

VZ.
  • 21,740
  • 3
  • 39
  • 42