我已经浏览了与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:Projectsbuild_0.02_audiobinDebugRashomon.exe : fatal error LNK1120: 37 unresolved externals
set()
命令设置一个变量。要将可执行文件与这些库链接,您需要
target_link_libraries(your_executable ${QT_LIBS})