Qt World Summit: Submit your Presentation


[solved] QXmpp - problem with undefined reference to



  • Hi,
    I try to use qxmpp library in my project (I don't want static linking), but while building there are some problems with this library: "undefined reference to...".
    I'm not sure if I do everything properly.
    I build qmpp library using Qt Creator as it was wrote in readme file.
    And I get build-qxmpp folder with builded library. Next I write:
    @
    INCLUDEPATH +=-L./build-qxmpp/src
    LIBS += qxmpp/src/base
    qxmpp/src/client
    qxmpp/src/server
    @

    And when I start to build my project the problem shows up.

    I saw common topic on forum, but there were advices to static linking, that I don't want to.
    Could you explain me where I do something wrong? Maybe I link wrong or my project is builded wrong.

    If you need any information please ask, I wish to solve this problem quick :D


  • Lifetime Qt Champion

    Hi,

    First thing I can see you have mixed these two statements:
    INCLUDEPATH is where you give the path to the headers
    LIBS is where you give the path to the libraries you link to and the libs themselves e.g.

    @LIBS += -Lpath_to_your_library -llibraryname_without_the_lib_prefix@



  • Sorry, wrong rewrite (I'm little bit tired)
    Of course I have:
    @
    LIBS +=-L./build-qxmpp/src
    INCLUDEPATH += qxmpp/src/base
    qxmpp/src/client
    qxmpp/src/server

    @


  • Lifetime Qt Champion

    You are still missing the -l with the library name



  • Ok, now I hav also -lqxmpp0
    But know it shows
    "cannot find -lqxmpp0"


  • Lifetime Qt Champion

    probably because:

    @-L./build-qxmpp/src@

    doesn't point to the right place. As a quick fix, give the full path to the folder containing the lib. You can then later add some logic to get it from the build dir.



  • I gave the full path to the library, but now it says:
    " cannot find C:... : Permission denied".
    But this folder exist, so I do not know why it cannot find it.



  • Ok, Now it works with full path to the library. Everything because of using forward slash instead of backslash. I checked it and instead of writing:

    @-Lbuild-qxmpp/src@
    I use:
    @-Lbuild-qxmpp\src@

    Thanks for help :D



  • I'm doing everything too fast. I have one more problem
    When I build/re-build project it works with:
    @-Lbuild-qxmpp\src@
    But when I compile it, it doesn't work with it, it works only if I use full path
    This is very strange.


  • Lifetime Qt Champion

    That's strange. Qt uses unix style forward slashes everywhere so it should work out of the box. Do you have spaces in your path ?

    build-qxmpp/src is a relative path. So depending on where the rest of your code is compiled, it can't be found at linking time


Log in to reply