mydoghasworms
mydoghasworms

Reputation: 18591

wxWidgets: Which files to link?

I am learning C++ and, in order to do so, am writing a sample wxWidgets application.

However, none of the documentation I can find on the wxWidgets website tell me what library names to pass to the linker.

Now, apart from wxWidgets, is there a general rule of thumb or some other convention by which I should/would know, for any library, what the names of the object files are against which I am linking?

Upvotes: 3

Views: 1991

Answers (3)

ultifinitus
ultifinitus

Reputation: 1893

We have more of a "rule of ring finger", instead of a thumb

Generally, if you compile the library by hand, it will produce several library files (usually .a .lib or something similar, depending entirely on your compiler and your ./configure) these are produced (typically) because of a makefile's build script.

Now a makefile can be edited in any way the developer pleases, but there are some good conventions (there is, in fact, a standard) many follow- and there are tools to auto generate the make files for the library (see automake)

Makefiles are usually consistent

You can simply use the makefile to generate the files, and if it's compliant, the files will be placed in a particular folder (the lib folder I believe?) all queued up and ready to use!

Keep in mind, a library file is simply the implementation of your code in precompiled format, you could create a library yourself from your code quite easily using the ar tool. Because it is code, just like any other code, you don't necessarily want to include all of the library files for a given library. For instance with wxWidgets if you're not using rich text, you certainly don't want to waste the extra space in your end executable by including that library file. Later if you want to use it, you can add it to your project (just like adding a .cpp file)

Oh and also with wxWidgets, in their (fantastic) documentation, each module will say what header you need to include, and what library it is a part of.

Happiness

Libraries are amazing, magical, unicorns of happiness. Just try not to get too frustrated with them and they'll prance in the field of your imagination for the rest of your programming career!

Upvotes: 1

VZ.
VZ.

Reputation: 22688

The build instructions are different for each platform and so you need to refer to the platform-specific files such as docs/gtk/install.txt (which mentions wx-config) or docs/msw/install.txt to find them.

FWIW wxWidgets project would also definitely gratefully accept any patches to the main manual improving the organization of the docs.

Upvotes: 1

mydoghasworms
mydoghasworms

Reputation: 18591

After a bit more Googling, I found a page on the wxWidgets wiki which relates to the Code::Blocks IDE, but which also works for me. By adding the following to the linker options, it picks up all the necessary files to link:

`wx-config --libs`

(So that does not solve my "general rule" problem; for any library I am working with, I still have to find out what files to link against, but at least this solves the problem for wxWidgets).

Upvotes: 1

Related Questions