I want to create a library in Mac OS X El Capitan (10.11.x) and use it in another application by qt creator, so I’ve created a simple library in qt with this setting:
QT -= gui
TARGET = /System/Library/Frameworks/MyFrm.framework/dylib/DynminLinkingLib
TEMPLATE = lib
As you can see I’ve created “DynminLinkingLib” library in MyFrm framework; after that I created a Qt Application to use the library.
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = SampleProject
TEMPLATE = app
macx: LIBS += -L/System/Library/Frameworks/MyFrm.framework/dylib -lDynminLinkingLib.1.0.0
INCLUDEPATH += /System/Library/Frameworks/MyFrm.framework/include
When I run my application in qt, it gives me this error:
dyld: Library not loaded: libDynminLinkingLib.1.dylib
Referenced from: /Users/mac/Src/dll/DynamicLinking/build-SampleProject-Desktop_Qt_5_5_0_clang_64bit-Debug/SampleProject.app/Contents/MacOS/SampleProject
Reason: image not found
The program has unexpectedly finished.
For resolving this error in Qt projects, I set DYLD_LIBRARY_PATH
variable to /System/Library/Frameworks/MyFrm.framework/dylib
and it works well, but when I run bundle application it doesn’t work and gives me this error:
This is because of “libDynminLinkingLib.1.dylib” is not in application path.
otool -D /System/Library/Frameworks/MyFrm.framework/dylib/libDynminLinkingLib.1.0.0.dylib
libDynminLinkingLib.1.dylib
I have two questions:
I know how to solve this problem by install_name_tool
but I want solve this problem in qmake and .pro file. So how can I solve this problem by pro config file?
In El Capitan, I can not use DYLD_LIBRARY_PATH
because of security reasons. In order to use it I must deactivate SIP (system integrity protection). So is there any way to use DYLD_LIBRARY_PATH without deactivating SIP?
This isn't a full solution but if you just want some local libraries you've built to be included while building something else you can create ~/lib
and ~/include
folders and put the files there. Those folders are on the default path.