PDA

View Full Version : Adding an external Library



afflictedd2
13th December 2008, 04:46
Hi everyone,

How do I add an external library to my qt project. Currently, I build simply by doing
qmake -project
qmake
make

but I need to add a CXXFLAGS and LDFLAGS to link with an external library as well.

Ted.

TomasC
13th December 2008, 06:51
You normally only use the command "qmake -project" once. This generates a project file (something.pro). This contains various settings about your application and how to build it.
To make it link in an additional library, you add the LIBS variable to this file:
LIBS += -lmylib
(that's "-l" (small L) directly followed by the library name).

If the library is in a directory the linker doesn't look in, you add the path to it to the LIBS variable:
LIBS += -L/path/to/my/lib -lmylib

On Windows, it is recommended to omit the -L, and just use the full path with -l, like:
LIBS += -lc:/path/to/my/lib/mylib.lib

When you are done editing the .pro file, save it and run qmake -makefile. This generates a makefile from your .pro file. Run the makefile by typing "make".

This and much much more is all explained in qmake-manual.