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.
Printable View
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.
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:
(that's "-l" (small L) directly followed by the library name).Code:
LIBS += -lmylib
If the library is in a directory the linker doesn't look in, you add the path to it to the LIBS variable:
Code:
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:
Code:
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.