3

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:

enter image description here

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:

  1. 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?

  2. 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?

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
Hadi Moghaddar
  • 115
  • 1
  • 11
  • *"i know how to configure this problem but install_name_tool "* - install_name_tool is the correct method for solving the problem. I don't believe you can do it via Qt Creator, or in the .pro – TheDarkKnight Nov 23 '15 at 15:05
  • The LIBS+= -L path -l filename directive can give version problems. Use first LIBS+= /absolute-path-to-my-dylib. Do not use symlinks but only the physical location. Rename if necessary. After that you can use the -L -l directive – adlag Dec 02 '15 at 20:30

1 Answers1

1

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.

https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/UsingDynamicLibraries.html

sclarson
  • 4,362
  • 3
  • 32
  • 44