Page 1 of 1

[SOLVED] Linker Settings

Posted: Fri Dec 13, 2019 9:08 am
by fmc
doublemax pointed me to a solution to fix my many errors when trying to compile the form you get when creating a wxWidgets app with C::B. The solution was to add four extra libraries, giving me a total of six libraries for the linker to link.

My questions is this: HOW do you know what libraries to link/add? The error log didn't show me anything that I recognized as a clue to add the other four libraries. So how do you know? This is a list of the errors I had. I posted them and that's when doublemax replied with a solution from another post that fixed this issue by adding the other libraries. So how do you wld I determine what libraries I'm suppose to add?

Re: Linker Settings

Posted: Fri Dec 13, 2019 9:58 am
by PB
The official wxWidgets documentation tells you which class belongs to which library.

In practice, the libraries do not number in dozens so you can just add them all and be done with it, once can tell which files and which order based on the sample project files or there is many posts in this forum listing them as well.

You usually do it once when starting with wxWidgets and then you just copy the project settings to new ones.

Re: Linker Settings

Posted: Fri Dec 13, 2019 10:16 am
by fmc
Hey, PB. I appreciate the response. I failed to read the wxWidgets docs, so that's my bad. I'll take my time and read them. I just thought that the errors might be pointing to the missing libraries. I was thinking the errors wld provide some sort of clue as to missing libraries the linker was missing/needing. Anyway, I'm good now and am working through some wxWidgets tutorials. I have a long way to learn all I need to be proficient, so my asking this was to see if the errors I got were clues to the needed libraries. If you don't ask, you won't know :D


Re: [SOLVED] Linker Settings

Posted: Fri Dec 13, 2019 10:38 am
by PB
For example, when you see an error like this

Code: Select all

C:/wxWidgets_3.1.3/include/wx/sckaddr.h:71: undefined reference to `_imp___ZN13wxSockAddressD2Ev'
It is obvious that the library with wxSockAddress is missing. If you go to wxSockAddress documentation, it lists wxNet under "Library:" When you click on the library name, you get to the libraries page, which on its top has a scheme of wxWidgets library dependencies.

As for the actual library names, it can get tricky but if you use an IDE with wxWidgets support such as Code::Blocks (and CodeLite?), its new project wizard will add the libraries for you. If you use MSVC, you do not need to add any libraries by hand as they are autolinked. If you use CMake, it should also be simple. If you are using makefiles or other ways, you need to take a look at the sample files which come with wxWidgets.