How to include library with it's own dependencies



  • I am trying to use the Gamma synthesis library in my Qt project (http://mat.ucsb.edu/gamma/). It has a dependency on libsndfile and portaudio. I am on Windows 10 and have built libsndfile and portaudio using msys the usual way with:

    ./configure
    make
    make install

    I then built Gamma in msys as well, no errors, although it does generate a .a file rather than a .dll.a. When I include the gamma lib in my Qt project and try and use the Gamma classes that depend on libsndfile or portaudio I get undefined port audio and libsndfile references and: "bad reloc address 0x5e" errors. I can include classes that do not depend on libsndfile or portaudio, which leads me to believe that the library is otherwise correctly built.

    Have I not provided the dependencies correctly? Could the Gamma library actually be trying to load these libraries at runtime? How could I check?

    Thanks!


  • Qt Champions 2016

    @Yosemite
    Hello,

    I then built Gamma in msys as well, no errors, although it does generate a .a file rather than a .dll.a.

    Judging from this, you seem to statically link the Gamma library in your project, is this correct? If so, are you adding the necessary linker flags to link against the Gamma's dependencies in your application? (Here's a discussion as to why you need to do this).

    Kind regards.



  • That thread was incredibly informative, many thanks! I actually had tried linking portaudio, but decided to take a look at what exactly I was including . I had linked to -llibportaudio, in the portaudio/lib directory (which contains both libportaudio.dll.a and libportaudio.a). I just noticed that in the portaudio/bin directory there was libportaudio-2.dll. Linking to that resolved the errors!

    If someone has the time to explain what the .dll.a and .a files are I would be really curious. Are those intermediate files created when I built the library, or something the .dll actually uses? I am assuming the former, because the project still builds when I remove them.


  • Qt Champions 2016

    @Yosemite
    The *.a file(s) is a static build of the said library. Usually on windows they're with extension *.lib, but sometimes when the project is ported from *nix to windows, the *.a extension is used (so it's compatible with *nix).

    Kind regards.



  • @kshegunov
    Sorry, there was a typo in my last post. The two files in portaudio/lib are libportaudio.dll.a and libportaudio.la (not .a).

    If I understand correctly the .la file is a libtool helper file. The .dll.a file appears to be a static import library, containing symbols exported from the library, which MinGW can link to in place of a .dll.

    http://stackoverflow.com/questions/15852677/static-and-dynamic-shared-linking-with-mingw

    I think I've learned enough to know that I do not need to worry about these files in Qt - my original problem was caused by mistaking them for the library.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.