将libmusicxml库添加到QtCreator中的项目中(使用VC 2012编译器)后,该项目将使用发行版配置(而不是调试配置)进行编译。在链接阶段,发生了许多构建问题,这些问题涉及尚未解决的外部符号。
阅读了其他文章后,我意识到我必须分别链接到两种配置的库。我尝试将以下变体添加到我的.pro文件中,但没有成功。
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
win32:CONFIG(release,debug | release):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
win32:CONFIG(release,debug | release):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):虚拟_thiscall MusicXML2::xmlreader::〜xmlreader(void)”(_imp _ ?? 1xmlreader @ MusicXML2 @@ UAE @ XZ)函数_main
希望有人能帮助我,在此先感谢!
最佳答案
在我们的项目中,我们这样做:
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
关于c++ - 将库添加到调试配置-QtCreator,VC编译器,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/17665981/