先看看qmake到 文档相关说明吧 。
Declaring Other Libraries
If you are using other libraries in your project in addition to those supplied with Qt, you need to specify them in your project file.
The paths that qmake searches for libraries and the specific libraries to link against can be added to the list of values in the LIBS variable. The paths to the libraries themselves can be given, or the familiar Unix-style notation for specifying libraries and paths can be used if preferred.
For example, the following lines show how a library can be specified:
LIBS += -L/usr/local/lib -lmath
The paths containing header files can also be specified in a similar way using the INCLUDEPATH variable.
For example, it is possible to add several paths to be searched for header files:
INCLUDEPATH = c:/msdev/include d:/stl/include
假设 我们的工程创建一个 project.pro
的 qmake 工程文件,例如:
# Input SOURCES = main.cpp Dialog.cpp Emitter.cpp HEADERS = Dialog.hpp Emitter.hpp CONFIG += qt TEMPLATE = app TARGET = DEPENDPATH += . INCLUDEPATH += . 我们为了 用boost_thread库,其中: 头文件 在:/usr/local/include/boost/thread.hpp 库文件 在:/usr/local/lib/boost/libboost_thread.so 和 /usr/local/lib/boost/libboost_thread.a 则 可以 在 项目文件(project.pro)中把 他们(路径) 分别加入到 qmake的 变量 INCLUDEPATH 和 LIBS 中去 如 下: INCLUDEPATH += /usr/local/include/boost LIBS += -L/usr/local/lib/boost/ -lboost_thread 这样在用qmake生成到 Makefile文件中就有了: ####### Compiler, tools and options CC = gcc CXX = g++ DEFINES = -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED CFLAGS = -m64 -pipe -g -Wall -W -D_REENTRANT $(DEFINES) CXXFLAGS = -m64 -pipe -g -Wall -W -D_REENTRANT $(DEFINES) INCPATH = -I/usr/local/Trolltech/Qt-4.6.2/mkspecs/linux-g++-64 -I. -I/usr/local/Trolltech/Qt-4.6.2/include/QtCore -I/usr/local/Trolltech/Qt-4.6.2/include/QtGui -I/usr/local/Trolltech/Qt-4.6.2/include -I. -I/usr/local/include/boost -I. LINK = g++ LFLAGS = -m64 -Wl,-rpath,/usr/local/Trolltech/Qt-4.6.2/lib LIBS = $(SUBLIBS) -L/usr/local/Trolltech/Qt-4.6.2/lib -L/usr/local/bin/boost -lboost_thread -lQtGui -L/usr/local/Trolltech/Qt-4.6.2/lib -L/usr/X11R6/lib64 -lQtCore -lpthread AR = ar cqs RANLIB = QMAKE = /usr/local/Trolltech/Qt-4.6.2/bin/qmake TAR = tar -cf COMPRESS = gzip -9f COPY = cp -f SED = sed COPY_FILE = $(COPY) COPY_DIR = $(COPY) -r STRIP = strip INSTALL_FILE = install -m 644 -p
####### Output directory
OBJECTS_DIR = ./ 。。。。。。 相关的boost_thread 库就加入 到项目 中去了,用 make产生 exe 就 没有一点问题 了