OSX Library not Loaded?
-
I have a Library named "libZip.dylib" that I have created with Qt, when I attempt to use it in a project, the application builds without any warnings or errors, but when I run the application it crashes with:
(Should note this builds and runs fine on both windows and linux)
/Users/bryancairns/Documents/Source/PluginService/Dist/AppTester
dyld: Library not loaded: libZip.dylibI have the application in:
/Users/bryancairns/Documents/Source/PluginService/Dist/I have the library in:
/Users/bryancairns/Documents/Source/PluginService/Dist/LibsA few google searches instructed me to try a few things, none of which are working...
Added to the project run settings:
DYLD_LIBRARY_PATH = /Users/bryancairns/Documents/Source/PluginService/Dist/LibsAdded to the applications project file different attempt to force linking:
QMAKE_RPATHDIR += /Users/bryancairns/Documents/Source/PluginService/Dist/LibsAnd then I tried...
QMAKE_LFLAGS += '-Wl,-rpath,'$$ORIGIN/../Libs''And then I tried...
QMAKE_LFLAGS += '-Wl,-rpath,/Users/bryancairns/Documents/Source/PluginService/Dist/Libs'Of course I am adding the LIBS but it seems to be a linking issue?
LIBS += -L$${DISTDIR}/Libs -lZipRan otool and the results are:
@
Bryans-MacBook-Pro:/ bryancairns$ otool -L /Users/bryancairns/Documents/Source/PluginService/Dist/AppTester
/Users/bryancairns/Documents/Source/PluginService/Dist/AppTester:
libZip.dylib (compatibility version 0.0.0, current version 0.0.0)
/Users/bryancairns/Qt/5.3/clang_64/lib/QtXml.framework/Versions/5/QtXml (compatibility version 5.3.0, current version 5.3.1)
/Users/bryancairns/Qt/5.3/clang_64/lib/QtCore.framework/Versions/5/QtCore (compatibility version 5.3.0, current version 5.3.1)
/Users/bryancairns/Qt/5.3/clang_64/lib/QtNetwork.framework/Versions/5/QtNetwork (compatibility version 5.3.0, current version 5.3.1)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 56.0.0)@
Almost looks like it is searching / for the lib?
Help I am a bit confused as to what i am doing wrong :) -
There may be dependency for libZip.dylib and they may not exist in your box. Check them. Since it says library is not loaded, I don't suspect the path issue. It may be just dependency issue.
How are you running the program ? Are you running from QtCreator or outside the Qt Creator env ? From QtCreator it should work fine if everything is fine with library. -
That's a very good point. I did fail to mention the libZip.dylib is simply a wrapper for ZLIB, which is compiled and placed in the same directory. I just assumed that setting QMAKE_RPATHDIR would set the search path for both of them.
/Users/bryancairns/Documents/Source/PluginService/Dist/Libs/libZip.dylib
/Users/bryancairns/Documents/Source/PluginService/Dist/Libs/libz.dylibSo would I have to add the QMAKE_RPATHDIR in the libZip as well pointing to ZLIB?
or would it just be easier to include the Zip code directly in the application and avoid libraries all together?
I am running the application from inside Qt Creator.