Results 1 to 5 of 5

Thread: Shared library symbols won't be found unless I use QTLibrary

  1. #1
    Join Date
    May 2009
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Shared library symbols won't be found unless I use QTLibrary

    Hi,

    I'm using QTCreator (first time) to build a project that links to a shared library.

    I've added (hopefully) the correct macros to the .pro file

    Qt Code:
    1. INCLUDEPATH += /path/to/include/
    2. LIBS += -L/path/to/lib -lmylib
    To copy to clipboard, switch view to plain text mode 

    but linking fails due to "undefined reference to" error.
    I managed to solve the problem by using QTLibrary as explained at the
    following link
    http://www.riverbankcomputing.co.uk/...y.html#details
    with the following example.

    Qt Code:
    1. QLibrary myLib("mylib");
    2. typedef void (*MyPrototype)();
    3. MyPrototype myFunction = (MyPrototype) myLib.resolve("mysymbol");
    4. if (myFunction)
    5. myFunction();
    To copy to clipboard, switch view to plain text mode 

    Now I'd like to understand what I'm doing wrong because I'm sure can't resolve all library symbols that way.

    Thanks in advance.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Shared library symbols won't be found unless I use QTLibrary

    Quote Originally Posted by emitrax View Post
    I've added (hopefully) the correct macros to the .pro file
    They are not macros, they are variables.

    but linking fails due to "undefined reference to" error.
    What is the exact filename of the library and where is it placed? Also what is the symbol the compiler complains about?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    May 2009
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Shared library symbols won't be found unless I use QTLibrary

    The library is place under my ~/lib and the path is added to ld.config. It is called libABC.so and it QTCreator does not see any symbol.

    Is there any particular linker or compilar default flags that could be blamed for this ?

  4. #4
    Join Date
    Mar 2009
    Posts
    98
    Thanks
    3
    Thanked 9 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Shared library symbols won't be found unless I use QTLibrary

    I create my first personal library with qtcreator. It's a class that I compile with the template lib in the project.

    I can use it without change anything in the ld.config.
    I set the variable LIBS in this way:
    unix:LIBS += -L/home/paceyiv/workspace/libs -lmyserialport
    where my library is called libmyserialport.so.1.1.0. (When I compile it create also some symbolic links: libmyserialport.so, libmyserialport.so.1 and libmyserialport.so.1.1)

    Try to compile with the full path.

    Exists a way to run my program in Linux without copy my library to /usr/lib ?

  5. #5
    Join Date
    Mar 2009
    Posts
    98
    Thanks
    3
    Thanked 9 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Shared library symbols won't be found unless I use QTLibrary

    To my question, the answer is app.addLibraryPath(const QString &AbsolutePath);

Similar Threads

  1. Visual Studio 2005 Express
    By Muzz in forum Installation and Deployment
    Replies: 22
    Last Post: 6th November 2008, 06:21
  2. mysql 5 connection
    By GuL in forum Newbie
    Replies: 37
    Last Post: 18th August 2008, 15:11
  3. exception at 0x65100c40 (QtGuid4.dll)
    By sabeesh in forum Qt Programming
    Replies: 11
    Last Post: 21st December 2007, 17:10
  4. Program crashes with assert error in xcb_lock.c
    By Valheru in forum Qt Programming
    Replies: 3
    Last Post: 18th November 2007, 19:56
  5. KDE 3.5.0 crash while opening project
    By MarkoSan in forum KDE Forum
    Replies: 2
    Last Post: 19th October 2007, 16:21

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.