How do I link a dynamic library with qmake into my app?
-
09-09-2019 - |
Question
In my qmake .pro file I add my desired dynamic library to LIB which allows for compilation but doesn't link to the library in the compiled application (i.e. I get a library not found error at run time).
The problem is that I have the library in my build directory, not in the system directory (i.e. /usr/lib). But, I want to generate a OSX app that doesn't touch the system outside of the .app folder.
Also, I'd link to know how to do this on a linux system - is it possible?
My question is related to the Qmake generating a proper .app question but differs in that the link that answers that question doesn't answer my question.
Solution
Put a wrapper script round your program so the current working directory is in the dynamic library search path:
#!/bin/bash
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:.
./program