将库添加到调试配置 - QtCreator,VC编译器

时间:2013-07-16 00:11:25

标签: c++ qt visual-c++ compilation linker

在QtCreator中将libmusicxml库添加到我的项目后(使用VC 2012编译器),项目将使用发布配置进行编译,但不使用调试配置。在链接阶段,会出现许多构建问题,这些问题会导致未解析的外部符号出现。

阅读完其他帖子后,我意识到我必须分别链接到两个配置的库。我尝试将以下变体添加到我的.pro文件中但没有任何成功。

  • 1

    LIBS + = -L $$ PWD /../ Libraries / libmusicxml-3.00-win32 / -llibmusicxml2

    INCLUDEPATH + = $$ PWD /../ Libraries / libmusicxml-3.00-win32 / include

    DEPENDPATH + = $$ PWD /../ Libraries / libmusicxml-3.00-win32 / include`

  • 2

    win32:CONFIG(发布,调试版|发布):LIBS + = -L $$ PWD /../ Libraries / libmusicxml-3.00-win32 / -llibmusicxml2

    else:win32:CONFIG(debug,debug | release):LIBS + = -L $$ PWD /../ Libraries / libmusicxml-3.00-win32 / -llibmusicxml2d

    INCLUDEPATH + = $$ PWD /../ Libraries / libmusicxml-3.00-win32 / include

    DEPENDPATH + = $$ PWD /../ Libraries / libmusicxml-3.00-win32 / include

  • 3,省略第3行中的d后缀

    win32:CONFIG(发布,调试版|发布):LIBS + = -L $$ PWD /../ Libraries / libmusicxml-3.00-win32 / -llibmusicxml2

    else:win32:CONFIG(debug,debug | release):LIBS + = -L $$ PWD /../ Libraries / libmusicxml-3.00-win32 / -llibmusicxml2

    INCLUDEPATH + = $$ PWD /../ Libraries / libmusicxml-3.00-win32 / include

    DEPENDPATH + = $$ PWD /../ Libraries / libmusicxml-3.00-win32 / include

错误消息看起来像

main.obj:-1:Fehler:LNK2019:未解析的外部符号“__declspec(dllimport)public:virtual _ thiscall MusicXML2 :: xmlreader :: ~xmlreader(void)”( _imp_ ?? 1xmlreader @ MusicXML2 @@ UAE @ XZ)在函数_main

中引用

我希望有人可以帮助我,提前谢谢!

1 个答案:

答案 0 :(得分:2)

在我们的项目中,我们这样做:

LIBS += -L$$PWD/../Libraries/libmusicxml-3.00-win32
win32 {
    CONFIG(debug, debug|release) {
        LIBS += -llibmusicxml2d
    } else {
        LIBS += -llibmusicxml2
    }
}
INCLUDEPATH += $$PWD/../Libraries/libmusicxml-3.00-win32/include

DEPENDPATH += $$PWD/../Libraries/libmusicxml-3.00-win32/include