简体   繁体   English

编译包含QtSerialPort的项目时出现链接器错误(g ++,kubuntu)

[英]Linker error while compiling project containing QtSerialPort (g++, kubuntu)

I am trying to compile a project that uses QtSerialPort and I get a link error 我正在尝试编译使用QtSerialPort的项目,但出现链接错误

g++ -m64 -Wl,-O1 -o eTerm main.o eterm.o tcpclient.o tcpserver.o udpserver.o serialserver.o qrc_eterm.o moc_eterm.o moc_tcpclient.o moc_tcpserver.o moc_udpserver.o moc_serialserver.o -L/usr/X11R6/lib64 -lQt5Widgets -L/usr/lib/x86_64-linux-gnu -lQt5SerialPort -ludev -lQt5Network -lQt5Gui -lQt5Core -lGL -lpthread /usr/bin/ld: cannot find -ludev collect2: error: ld returned 1 exit status make: *** [eTerm] Error 1 g ++ -m64 -Wl,-O1 -o eTerm main.o eterm.o tcpclient.o tcpserver.o udpserver.o serialserver.o qrc_eterm.o moc_eterm.o moc_tcpclient.o moc_tcpserver.o moc_udpserver.o moc_serialserver.o -L / usr / X11R6 / lib64 -lQt5小部件-L / usr / lib / x86_64-linux-gnu -lQt5SerialPort -ludev -lQt5Network -lQt5Gui -lQt5Core -lGL -lpthread / usr / bin / ld:找不到-ludev collect2:错误:返回ld 1个退出状态:*** [eTerm]错误1

I am using QtCreator 5.2.1 under Kubuntu 14.04 我正在Kubuntu 14.04下使用QtCreator 5.2.1

udev is installed and is the last version. udev已安装,是最新版本。 I only get this error when QtSerialPort is included / used, everything is fine for other projects. 仅当包含/使用QtSerialPort时,才会出现此错误,对于其他项目来说一切都很好。

#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
    #include <QtSerialPort/QtSerialPort>
#else
    #include <QSerialPort>
    #include <QSerialPortInfo>
#endif

The serial port is installed from libqt5serialport5-dev and libqt5serialport5 packages (I had some unsuccessful trials to install it from source at first). 串行端口是从libqt5serialport5-dev和libqt5serialport5软件包安装的(我尝试过一些不成功的尝试,首先是从源代码安装它)。

Does anyone has an idea what could be causing this problem? 有谁知道会导致这个问题的原因吗? Thanks! 谢谢!

Try to install package libudev-dev . 尝试安装软件包libudev-dev For compiling you normally need a package ending on -dev which contains special compilation files. 要进行编译,通常需要一个以-dev结尾的软件包,其中包含特殊的编译文件。 The packages without -dev are usually only for running programs which dynamically link to a library. 没有-dev的软件包通常仅用于运行程序,这些程序可以动态链接到库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM