Results 1 to 3 of 3

Thread: Linking with third-party libraries

  1. #1
    Join Date
    Nov 2010
    Posts
    77
    Thanks
    17
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Linking with third-party libraries

    I'm trying to use two external libraries called jrtplib and jthread within a Qt project, but I'm not sure how I do this. I've compiled it from source and I've obtained shared objects named libjrtp.so.3.9.1 and libjrtp.so.3.9.1. I added the header files as well.

    These are the files I copied from the source:

    Qt Code:
    1. > ls -R headers
    2. headers:
    3. jrtplib jthread
    4.  
    5. headers/jrtplib:
    6. rtcpapppacket.h rtpbyteaddress.h rtpkeyhashtable.h rtpsessionparams.h
    7. rtcpbyepacket.h rtpcollisionlist.h rtplibraryversion.h rtpsessionsources.h
    8. rtcpcompoundpacketbuilder.h rtpconfig.h rtpmemorymanager.h rtpsourcedata.h
    9. rtcpcompoundpacket.h rtpdebug.h rtpmemoryobject.h rtpsources.h
    10. rtcppacketbuilder.h rtpdefines.h rtppacketbuilder.h rtpstructs.h
    11. rtcppacket.h rtperrors.h rtppacket.h rtptimeutilities.h
    12. rtcprrpacket.h rtpexternaltransmitter.h rtppollthread.h rtptransmitter.h
    13. rtcpscheduler.h rtphashtable.h rtprandom.h rtptypes.h
    14. rtcpsdesinfo.h rtpinternalsourcedata.h rtprandomrand48.h rtptypes_win.h
    15. rtcpsdespacket.h rtpipv4address.h rtprandomrands.h rtpudpv4transmitter.h
    16. rtcpsrpacket.h rtpipv4destination.h rtprandomurandom.h rtpudpv6transmitter.h
    17. rtcpunknownpacket.h rtpipv6address.h rtprawpacket.h
    18. rtpaddress.h rtpipv6destination.h rtpsession.h
    19.  
    20. headers/jthread:
    21. jmutexautolock.h jmutex.h jthreadconfig.h jthread.h
    22. > ls -R libs
    23. libs:
    24. libjrtp.so libjrtp.so.3.9.1 libjthread.so libjthread.so.1.3.1
    To copy to clipboard, switch view to plain text mode 

    I added the following flag to the qmake file:

    Qt Code:
    1. INCLUDEPATH += ../headers
    2. LIBS += ../libs/libjrtp.so ../libs/libjthread.so
    To copy to clipboard, switch view to plain text mode 

    To test the library, I added #include <jthread/jmutex.h> and put this in the main function:

    Qt Code:
    1. jthread::JMutex mutex;
    2. mutex.Lock();
    3. mutex.Unlock();
    To copy to clipboard, switch view to plain text mode 

    I see this when I try to run this program:

    Qt Code:
    1. Debugging starts
    2. &"warning: GDB: Failed to set controlling terminal: Invalid argument\n"
    3. error while loading shared libraries: libjrtp.so.3.9.1: cannot open shared object file: No such file or directory
    4. Debugging has finished
    To copy to clipboard, switch view to plain text mode 

    This looks like a dynamic linking failure. Other than that I've seen no warning signs. What am I doing wrong? Perhaps there is a way to statically link with jrtplib to avoid issues. I realize that I didn't use LIBS like everyone else (LIBS += -l../libs/libjrtp.so -l../libs/libjthread.so), but that only gave me more errors. Leaving out the LIBS statement quite logically causes qmake to fail to link to the library (undefined reference to `jthread::JMutex::JMutex()' etc).

  2. #2
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Linking with third-party libraries

    Under Linux, the recommended approach is to install your 3rd party libraries in standard system locations (headers in /usr/include and shared libs in /usr/lib for instance). This has two benefits :
    • you can use the more portable
      Qt Code:
      1. LIBS += -ljrtp
      To copy to clipboard, switch view to plain text mode 
      idiom in the project file and dispense from specifying an extra include path
    • you don't have to worry about LD_LIBRARY_PATH (this is the reason the shared lib is not found in your case)
    If you want to bundle the 3rd party libs with your app, the best approach is probably static linking (provided it is supported by the libs of interest).
    Current Qt projects : QCodeEdit, RotiDeCode

  3. The following user says thank you to fullmetalcoder for this useful post:

    blooglet (22nd December 2011)

  4. #3
    Join Date
    Nov 2010
    Posts
    77
    Thanks
    17
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Linking with third-party libraries

    That worked for me. Thanks for your advice!

Similar Threads

  1. compiling QT with third party libraries
    By arjoshi in forum Newbie
    Replies: 1
    Last Post: 6th March 2011, 15:40
  2. Your favourite/recommended third-party libraries
    By agarny in forum General Discussion
    Replies: 4
    Last Post: 27th January 2011, 11:38
  3. macdeployqt and third party libraries
    By calumcjr in forum Installation and Deployment
    Replies: 0
    Last Post: 10th May 2010, 21:20
  4. Linking Third party Libraries
    By jsmith in forum Qt Programming
    Replies: 1
    Last Post: 13th October 2009, 06:18
  5. Using third-party libraries in qt
    By apj in forum Newbie
    Replies: 1
    Last Post: 15th May 2009, 22:27

Tags for this Thread

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.