Qt-对..的未定义引用(Ubuntu 14.04 LTS 64位)

Qt - undefined reference to... (Ubuntu 14.04 LTS 64 bits)

本文关键字:LTS 64位 Ubuntu 未定义 引用 Qt-      更新时间:2023-10-16

我试着用Qt5.3.1 MSVC2012编译我用windows 7 64位制作的一个项目,现在用Unbuntu 14.04 LTS编译Qt5.4 gcc 64位。

但我有一些"未定义的参考"错误:

/home/inncore/Software/CES_2015/trunk/MainProgram//bin//libSmartphoneController.a(smartphonecontroller.o):在函数SmartphoneController::init()': /home/innocore/Software/CES_2015/trunk/bin/../LibSmartphoneController/smartphonecontroller.cpp:11: undefined reference to中RemoteADBInterface::RemoteADBInterface(QString,QString、int、QObject*)'/home/inncore/Software/CES_2015/trunk/bin//LibSmartphoneController/smartphoneControl.cpp:13:对RemoteADBInterface::newMessage(RemoteADBInterface::Message const&, QVariant const&)' /home/innocore/Software/CES_2015/trunk/MainProgram/../bin//libSmartphoneController.a(smartphonecontroller.o): In function QMetaObject::Connection QObject::connect,Qt::ConnectionType)':/opt/5.4/gcc_64/include/QtCore/qobject.h:239:对"RemoteADBInterface::staticMetaObject"的未定义引用collect2:错误:ld返回1退出状态

我的项目由一个exe和几个库组成,如libSmartphoneController.a或libRemoteADB.a

所有库都能正确编译,并在正确的目录中创建。当我编译我的exe程序(MainProgram)时会出现问题。在.pro中,我确信我包含了正确的依赖项:

unix:!macx {
CONFIG(release, release|debug) {
LIBS += -L$$PWD/../Lib/ -lAudioPlayer -lDisplay -lSWCom -lRemoteADB -lDMS -lTVRemote 
                        -lHDMIMixer -lSmartphoneController -lRemoteServer
}
CONFIG(debug, release|debug) {
LIBS += -L$$PWD/../bin/ -lAudioPlayer -lDisplay -lSWCom -lRemoteADB -lDMS -lTVRemote 
                        -lHDMIMixer -lSmartphoneController -lRemoteServer
} }

lib Smartphone Controller还有两个依赖项:

在Smartphone Controller.pr:中

unix:!macx {
CONFIG(release, release|debug) {
LIBS += -L$$PWD/../Lib/ -lRemoteADB -lRemoteServer
}
CONFIG(debug, release|debug) {
LIBS += -L$$PWD/../bin/ -lRemoteADB -lRemoteServer
} }

问题是它在库RemoteADB中找不到某些函数的定义(构造函数,signal readMessage…)。我对所有其他库没有任何问题+它在windows上完美编译。。。

知道吗?

提前感谢您的帮助

我看到了问题的一个可能原因:编译器找不到库文件,你可以通过在.pro文件中添加保存库的完整路径来解决这个问题,我在这里看到的是,如果正在编译调试或发布,你有不同的搜索库的路径,你确定这两个地方都有正确的库吗?这将是一个在你的专业文件中放什么的例子:

LIBS+=-L$$OUT_PWD/../..//项目/mylibs/release/