install qtSerialPort library

I want to install qtserialport in precise1-Ubuntu. I got the source directory using git. next I download lib-qt4-dev and qmake. I ran qmake. it works fine. but, make fails with the following error:

    cd src/ && make -f Makefile 
make[1]: Entering directory `/home/saman/5.0.1/serialPortSrc/qtserialport/src'
cd serialport/ && make -f Makefile 
make[2]: Entering directory `/home/saman/5.0.1/serialPortSrc/qtserialport/src/serialport'
make[2]: Nothing to be done for `first'.
make[2]: Leaving directory `/home/saman/5.0.1/serialPortSrc/qtserialport/src/serialport'
make[1]: Leaving directory `/home/saman/5.0.1/serialPortSrc/qtserialport/src'
cd examples/ && make -f Makefile 
make[1]: Entering directory `/home/saman/5.0.1/serialPortSrc/qtserialport/examples'
cd cenumerator/ && make -f Makefile 
make[2]: Entering directory `/home/saman/5.0.1/serialPortSrc/qtserialport/examples/cenumerator'
g++ -Wl,-O1 -o cenumerator main.o    -L/usr/lib/i386-linux-gnu -lQtGui -lQtCore -lpthread 
main.o: In function `QList<QSerialPortInfo>::free(QListData::Data*) [clone .isra.1]':
main.cpp:(.text+0x47): undefined reference to `QSerialPortInfo::~QSerialPortInfo()'
main.o: In function `QList<QSerialPortInfo>::detach_helper(int)':
main.cpp:(.text._ZN5QListI15QSerialPortInfoE13detach_helperEi[QList<QSerialPortInfo>::detach_helper(int)]+0x68): undefined reference to `QSerialPortInfo::QSerialPortInfo(QSerialPortInfo const&)'
main.cpp:(.text._ZN5QListI15QSerialPortInfoE13detach_helperEi[QList<QSerialPortInfo>::detach_helper(int)]+0xc3): undefined reference to `QSerialPortInfo::~QSerialPortInfo()'
main.o: In function `main':
main.cpp:(.text.startup+0x5e): undefined reference to `QSerialPortInfo::availablePorts()'
main.cpp:(.text.startup+0x10f): undefined reference to `QSerialPortInfo::isBusy() const'
main.cpp:(.text.startup+0x16b): undefined reference to `QSerialPortInfo::hasProductIdentifier() const'
main.cpp:(.text.startup+0x1bb): undefined reference to `QSerialPortInfo::hasVendorIdentifier() const'
main.cpp:(.text.startup+0x212): undefined reference to `QSerialPortInfo::manufacturer() const'
main.cpp:(.text.startup+0x24a): undefined reference to `QSerialPortInfo::description() const'
main.cpp:(.text.startup+0x282): undefined reference to `QSerialPortInfo::systemLocation() const'
main.cpp:(.text.startup+0x2ba): undefined reference to `QSerialPortInfo::portName() const'
main.cpp:(.text.startup+0x644): undefined reference to `QSerialPortInfo::productIdentifier() const'
main.cpp:(.text.startup+0x674): undefined reference to `QSerialPortInfo::vendorIdentifier() const'
collect2: ld returned 1 exit status
make[2]: *** [cenumerator] Error 1
make[2]: Leaving directory `/home/saman/5.0.1/serialPortSrc/qtserialport/examples/cenumerator'
make[1]: *** [sub-cenumerator-make_default-ordered] Error 2
make[1]: Leaving directory `/home/saman/5.0.1/serialPortSrc/qtserialport/examples'
make: *** [sub-examples-make_default-ordered] Error 2

although make fails, I can now include qtserialport header to my project. and about the failure, I checked main.cpp, it includes serialPortSrcInfo.so, this .so file has already been generated when qmake was called. how can I fix the problem?


AFAIK it is based on Qt5+. I am using Qtserial in my project (pilotnavigator). My QTSDK 5+ is installed locally (not via apt). These are the instructions.

  • Copy qtplayground-qtserialport folder into a local folder (preferably where your Qt projects are). Example: ~/yourqtprojectfolder/pilotnavigator/qtplayground-qtserialport
  • Create a build folder at the same level called qtplayground-qtserialport-build in pilotnavigator folder. Example: ~/yourqtprojectfolder/pilotnavigator/qtplayground-qtserialport-build

Find out where qmake lives. Normaly it is located in your Qt5 folder, probably ~/Qt5x.x.x/5.x.x/gcc_64/bin

Open a Linux Terminal\

cd to the qtplayground-qtserialport-build folder. Example cd ~/yourqtprojectfolder/pilotnavigator/qtplayground-qtserialport-build

run qmake. Example:

~/Qt5x.x.x/5.x.x/gcc_64/bin/qmake ~/yourqtprojectfolder/pilotnavigator/qtplayground-qtserialport/qtserialport.pro
make

(If you get an error concerning missing file libudev.h, you need to install the libudev-dev library, e.g. sudo apt-get install libudev-dev)

sudo make install