0

我已经阅读了有关 LNK2019 和 LNK2001 的所有建议,但似乎没有解决我的问题。我的问题与声子和 DLL 有关,但我不知道如何链接必要的库,因为我的项目没有.pro文件。我正在使用 vsaddin 和 vs2010 以及 cmake。cmake 确实有如下一行:

set( QT_LIBS QtCore QtGui QtNetwork QtSvg QtWebKit QtXml QtXmlPatterns phonon )

我得到的错误如下:

12>MainWindow.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall Phonon::Path::~Path(void)" (__imp_??1Path@Phonon@@QAE@XZ) referenced in function "public: __thiscall MainWindow::MainWindow(class QString const &,class QWidget *,class QFlags<enum Qt::WindowType>)" (??0MainWindow@@QAE@ABVQString@@PAVQWidget@@V?$QFlags@W4WindowType@Qt@@@@@Z)
12>MainWindow.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) class Phonon::Path __cdecl Phonon::createPath(class Phonon::MediaNode *,class Phonon::MediaNode *)" (__imp_?createPath@Phonon@@YA?AVPath@1@PAVMediaNode@1@0@Z) referenced in function "public: __thiscall MainWindow::MainWindow(class QString const &,class QWidget *,class QFlags<enum Qt::WindowType>)" (??0MainWindow@@QAE@ABVQString@@PAVQWidget@@V?$QFlags@W4WindowType@Qt@@@@@Z)
12>MainWindow.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall Phonon::MediaObject::setTickInterval(int)" (__imp_?setTickInterval@MediaObject@Phonon@@QAEXH@Z) referenced in function "public: __thiscall MainWindow::MainWindow(class QString const &,class QWidget *,class QFlags<enum Qt::WindowType>)" (??0MainWindow@@QAE@ABVQString@@PAVQWidget@@V?$QFlags@W4WindowType@Qt@@@@@Z)

...

12>MainWindow.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall Phonon::AudioOutput::metaObject(void)const " (?metaObject@AudioOutput@Phonon@@UBEPBUQMetaObject@@XZ)
12>MainWindow.obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall Phonon::AudioOutput::qt_metacast(char const *)" (?qt_metacast@AudioOutput@Phonon@@UAEPAXPBD@Z)
12>MainWindow.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall Phonon::AudioOutput::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@AudioOutput@Phonon@@UAEHW4Call@QMetaObject@@HPAPAX@Z)
12>MainWindow.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall Phonon::MediaObject::metaObject(void)const " (?metaObject@MediaObject@Phonon@@UBEPBUQMetaObject@@XZ)
12>MainWindow.obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall Phonon::MediaObject::qt_metacast(char const *)" (?qt_metacast@MediaObject@Phonon@@UAEPAXPBD@Z)
12>MainWindow.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall Phonon::MediaObject::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@MediaObject@Phonon@@UAEHW4Call@QMetaObject@@HPAPAX@Z)

...

12>F:\Projects\build_0.02_audio\bin\Debug\Rashomon.exe : fatal error LNK1120: 37 unresolved externals
4

1 回答 1

0

set()命令设置一个变量。要将您的可执行文件与这些库链接,您需要

target_link_libraries(your_executable ${QT_LIBS})
于 2012-10-01T13:32:56.123 回答