Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved]Undefined reference problem
QtWS25 Last Chance

[Solved]Undefined reference problem

Scheduled Pinned Locked Moved General and Desktop
11 Posts 3 Posters 3.9k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SetBetterPass
    wrote on last edited by
    #1

    I've installed qxmpp library recently and wanted to write small program. I included QXmppClient.h and after some problems at start I managed to set it and included as any other qt header. But there came the problem, creating simple variable QXmppClient client; gave me these errors

    /root/IM_client-build-desktop/../IM_client/reg_okno.cpp:47: error: undefined reference to QXmppClient::QXmppClient(QObject*)' /root/IM_client-build-desktop/../IM_client/reg_okno.cpp:50: error: undefined reference to QXmppClient::~QXmppClient()'

    I changed it to QXmppClient *client; and error disappeared but now after this client->connectToServer("blahblah","test"); I got the error again
    /root/IM_client-build-desktop/../IM_client/reg_okno.cpp:56: error: undefined reference to `QXmppClient::connectToServer(QString const&, QString const&)'

    I don't think there is problem with header because after typing client-> qt creator showed up all existing members of QXmppClient class in menu (I don't know how its called :)) as expected.
    I'll be thankful for any help or hint :)

    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      Do you link with the correct lib?

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SetBetterPass
        wrote on last edited by
        #3

        The example gave me this error when run

        /root/static_im/qxmpp-0.7.6/examples/example_0_connected-build-desktop/example_0_connected: error while loading shared libraries: libqxmpp_d.so.0: cannot open shared object file: No such file or directory

        I've tried to add LIBS += -L/usr/local/lib to .pro file to tell linker where to find lib but it didn't help, will be probably the same problem in my own code, how can I force linker to look there for the lib file?

        1 Reply Last reply
        0
        • K Offline
          K Offline
          koahnig
          wrote on last edited by
          #4

          Upper case 'L' defines the path of the library, but need also to specify the static part of the lib with lower case 'l'. See "this":http://qt-project.org/doc/qt-5.0/qtdoc/qmake-variable-reference.html#libs

          Vote the answer(s) that helped you to solve your issue(s)

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SetBetterPass
            wrote on last edited by
            #5

            changed it to LIBS += -L/usr/local/lib -lqxmpp_d but nothing happened, application still crashing with same message

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Hi,

              There's something not clear, once you have a problem when compiling, then when running the application.

              So maybe a silly question but: are you sure you have libqxmpp_d.so.0 on your system ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • S Offline
                S Offline
                SetBetterPass
                wrote on last edited by
                #7

                yes, the libqxmpp_d.so.0 file is link to shared library libqxmpp_d.so.0.7.6 it's in same directory as the lib, /usr/local/lib

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Just to make things clear: did you build your application successfully ?

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    SetBetterPass
                    wrote on last edited by
                    #9

                    yes, no error nor warning when building it, only when I run application it crashes with that error

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      Then you need to update LD_LIBRARY_PATH and make it point also to /usr/local/lib.

                      By the way, developing (and generally doing anything) as root user is very dangerous, you could end up destroying your OS.

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0
                      • S Offline
                        S Offline
                        SetBetterPass
                        wrote on last edited by
                        #11

                        Thank you really much this was exactly the problem, next time I'll know :)

                        1 Reply Last reply
                        0

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved