Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Adding libudev & tinyxml libraries to my QT compiler



  • I've been searching everywhere on how to do this and kind of getting frustrated because nothing seems to work.

    I am working with QT 5.5.1 on Ubuntu 16.04.5 LTS
    I have downloaded tinyxml online, and installed libudev-dev from my terminal. When I try to use either of these libraries, it gives me undefined reference to 'blah blah' which are classes that are in the headerfiles. I found a lot of posts telling me to link the library to my project, but when I run something like:~projectname$ gcc -Wall -o main main.cpp -ludev, it gives me
    fata error:QCoreApplication: No such file or directory. Is there a simple and effective way to link the libraries to my project?

    test.pro
    QT += core
    QT -= gui
    QT += widgets

    TARGET = test
    CONFIG += console
    CONFIG += qt
    CONFIG -= app_bundle

    LIBS += -l/usr/lib/arm-linux-gnueabihf/libtinyxml.a
    TEMPLATE = app

    SOURCES += main.cpp

    Also, everything I change something on my .pro file, my QT compiler outputs: /usr/lib/distcc/bin/g++-5:command not found.

    Then I have to go to my Makefile and change CC & CXX from /usr/lib/distcc/bin/gcc-t to just gcc-5 & g++-5 and then it works. Are there any other settings I have to change in order for my compiler to do this automatically so I don't have to keep changing this every time I try to link something.



  • Got it.
    I added

    CONFIG += link_pkgconfig
    DEFINES += LINK_LIBUDEV
    PKGCONFIG += libudev

    to my .pro file and it works now.


  • Lifetime Qt Champion

    Hi,

    Are you cross-compiling your application ?
    Are you building your application on an ARM machine ?



  • @SGaist I am building my application on an ARM machine (armv7l). I've been able to compile other console applications with different libraries, but these two seem to be giving me problems.
    I'm new here so I had to wait 10 minutes lol



  • Got it.
    I added

    CONFIG += link_pkgconfig
    DEFINES += LINK_LIBUDEV
    PKGCONFIG += libudev

    to my .pro file and it works now.



  • If I may add my two cents, since you're using QtCore, why not using QXmlStreamReader? I had experience with tinyxml: the whole data is loaded (which was a problem for me) and the syntax is very close to C... This would save you from importing / compiling a new library.



  • @user614 glad you found the solution. So if your issue is solved, please mark your post as such!. Thanks.


Log in to reply