Results 1 to 6 of 6

Thread: Qmake fails to set shared library dependency

  1. #1
    Join Date
    Apr 2009
    Posts
    13
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Qmake fails to set shared library dependency

    Hi,

    Not sure if this really Qt specific problem, but here goes...

    I have a Qt gui-project which directory structure after successful build should look like follows (only relevant stuff to my problem, below)

    Qt Code:
    1. LibBap/ // Links with muparser
    2. LibBap.pro
    3. <sources>
    4. Bap/ // Links with LibBap
    5. Bap.pro
    6. <sources>
    7. BapPlugin/ // Links with LibBap
    8. BapPlugin.pro
    9. <sources>
    10. Extra/
    11. muparser/
    12. muparser.pro
    13. <sources>
    14. bin/
    15. Bap
    16. lib/
    17. libLibBap.so
    18. libmuparser.so
    19. libBapPlugin.so
    To copy to clipboard, switch view to plain text mode 

    Build steps before error:

    1) libmuparser.so
    - built only if system doesn't have this already installed
    - compiles/links fine
    - moved to bin/lib

    2) libLibBap.so
    - links with libmuparser.so (either the one in bin/lib or system /usr/lib)
    - compiles/links fine
    - moved to to bin/lib/

    3) Bap
    - main executable
    - links directly with libLibBap.so (and indirectly on libmuparser.so)
    - compiles ok, but linker gives error:

    g++ -o ../bin/Bap <objects> -L/usr/lib64/qt4 -L../bin/lib -lBapLib <bunch of -llibs> /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/../../../../x86_64-pc-linux-gnu/bin/ld: warning: libmuparser.so.1, needed by ../bin/lib/libBapLib.so, not found (try using -rpath or -rpath-link)
    ../bin/lib/libBapLib.so: undefined reference to `mupGetErrorMsg(void*)'
    ../bin/lib/libBapLib.so: undefined reference to `mupCreate()'
    ../bin/lib/libBapLib.so: undefined reference to `mupRelease(void*)'
    ../bin/lib/libBapLib.so: undefined reference to `mupError(void*)'
    ../bin/lib/libBapLib.so: undefined reference to `mupEval(void*)'
    ../bin/lib/libBapLib.so: undefined reference to `mupSetExpr(void*, char const*)'
    ../bin/lib/libBapLib.so: undefined reference to `mupDefineVar(void*, char const*, double*)'
    ../bin/lib/libBapLib.so: undefined reference to `mupSetVarFactory(void*, double* (*)(char const*, void*), void*)'

    So from above it seems to me that linker ignores search path (-L../bin/lib) as it resolves dependencies (libmuparser.so) of libraries linked with -l flag (libBapLib.so).

    If I do 'LD_LIBRARY_PATH=../bin/lib make' in Bap/ OR install muparser in /bin/lib instead there is no error. But neither of these is suitable solution in long term.

    I tried -rpath and -rpath-link in qmake LIBS variable as the linker suggests but no success. I also tried create_prl and link_prl for BapLib.pro and Bap.pro but no effect. But maybe there is some linker flag or qmake variable that sorts these kind of problems ? I hope there is some obvious thing I missed...

    What can I do to let linker know of the second library ?

    Thanks!

  2. #2
    Join Date
    Dec 2008
    Location
    TaganrogNativelandChehov,Russia
    Posts
    64
    Thanks
    1
    Thanked 8 Times in 7 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qmake fails to set shared library dependency

    strange ...

    libmuparser.so.1
    east or west home is best

  3. #3
    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: Qmake fails to set shared library dependency

    Do you have "libmuparser.so.1" in bin/lib?
    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.


  4. #4
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qmake fails to set shared library dependency

    add path to the library to /etc/ld.so.conf and run ldconfig (as root)
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  5. #5
    Join Date
    Apr 2009
    Posts
    13
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qmake fails to set shared library dependency

    Do you have "libmuparser.so.1" in bin/lib?
    Yep. qmake/make creates 4 files in bin/lib: libmuparser.so.1.0.0 which is regular file and libmuparser.so, libmuparser.so.1 and libmuparser.so.1.0 which are all links to the first one.

    However I managed to fix this problem by appending -lmuparser to LIBS in Bap.pro. Maybe it was not clear in OP but I didn't have that in the original linker build commandline; I would have thought linker was clever enough to pick up indirect libarary dependencies from -L../bin/lib.

    Now I have -lmuparser flag in both BapLib and Bap projects link commands and it seems to work but is it possible there are now duplicated muparser symbols or something in 'Bap' that are not really used at all and take space because it's actually only BapLib code that calls muparser functions ? Or does linker need libmuparser.so just to check that the function definitions do exist (somewhere) ?

  6. #6
    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: Qmake fails to set shared library dependency

    Nothing is duplicated, this is dynamic linkage - it only says "hey, I depend on X and Y" and X says "hey, I depend on Y" so at runtime the linker thinks "hey, the app depends on X and Y and X depends on Y, so I need to link Y and X before running the app".
    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.


Similar Threads

  1. Replies: 4
    Last Post: 20th May 2009, 11:20
  2. qmake: dependency of application on common shared library
    By PeterWurmsdobler in forum Qt Programming
    Replies: 5
    Last Post: 27th March 2009, 17:13
  3. Shared Library Creation
    By tntcoda in forum Qt Programming
    Replies: 1
    Last Post: 1st February 2009, 00:48
  4. Adding library dependencies to qmake
    By sadastronaut in forum Installation and Deployment
    Replies: 2
    Last Post: 18th March 2008, 18:06
  5. shared library problem
    By nhatkhang in forum KDE Forum
    Replies: 9
    Last Post: 28th November 2006, 05:07

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.