这很有可能会被否决,但由于我在任何地方都找不到答案,因此我仍在发布此信息。我已经在项目中添加了一个静态外部库,这就是MyApp.pro目前的样子:
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../common/build-CommonLib-Desktop_Qt_5_3_MSVC2012_OpenGL_32bit-Release/release/ -lCommonLib
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../common/build-CommonLib-Desktop_Qt_5_3_MSVC2012_OpenGL_32bit-Release/release/ -lCommonLibd
else:unix: LIBS += -L$$PWD/../common/build-CommonLib-Desktop_Qt_5_3_MSVC2012_OpenGL_32bit-Release/release/ -lCommonLib
INCLUDEPATH += $$PWD/../common/build-CommonLib-Desktop_Qt_5_3_MSVC2012_OpenGL_32bit-Release/release
DEPENDPATH += $$PWD/../common/build-CommonLib-Desktop_Qt_5_3_MSVC2012_OpenGL_32bit-Release/release
win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../common/build-CommonLib-Desktop_Qt_5_3_MSVC2012_OpenGL_32bit-Release/release/libCommonLib.a
else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../common/build-CommonLib-Desktop_Qt_5_3_MSVC2012_OpenGL_32bit-Release/release/libCommonLibd.a
else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../common/build-CommonLib-Desktop_Qt_5_3_MSVC2012_OpenGL_32bit-Release/release/CommonLib.lib
else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../common/build-CommonLib-Desktop_Qt_5_3_MSVC2012_OpenGL_32bit-Release/release/CommonLibd.lib
else:unix: PRE_TARGETDEPS += $$PWD/../common/build-CommonLib-Desktop_Qt_5_3_MSVC2012_OpenGL_32bit-Release/release/libCommonLib.a
但是,我仍然不确定如何从项目中的头文件引用库(以及其中的特定头文件)。我尝试做
#include<CommonLib/Test.h>
,但是它无法识别CommonLib
或CommonLib/Test.h
。 最佳答案
您的INCLUDEPATH
指向构建目录,而库头很可能在带有CommonLib
源的目录中。