Missing dylib libraries
If your application using some externals dynamic libraries (called .dylib in MacOs system), you have to provide all these libraries. The simplest way is to provide these libraries into the Application.app directory.
Find out which libraries are used
Qt provide really useful tool called “otool” which serves to lots of purpose. One of them is to detect which shared libraries are required by our application. For this purpose otool has parameter -L. The usage is following:
otool -L ./Test1.app/Contents/MacOS/Test1
Output could looks like this:
./Test1: libboost_iostreams.dylib (compatibility version 0.0.0, current version 0.0.0) libboost_filesystem.dylib (compatibility version 0.0.0, current version 0.0.0) libboost_system.dylib (compatibility version 0.0.0, current version 0.0.0) libboost_thread.dylib (compatibility version 0.0.0, current version 0.0.0) libboost_date_time.dylib (compatibility version 0.0.0, current version 0.0.0) libboost_regex.dylib (compatibility version 0.0.0, current version 0.0.0) /Users/dev/dev/SharedLibraries/libiconv/lib/libiconv.2.dylib (compatibility version 8.0.0, current version 8.0.0) /Users/dev/dev/ExternalLibraries/../SharedLibraries/libxml/lib/libxml2.2.dylib (compatibility version 10.0.0, current version 10.8.0) /Users/dev/dev/ExternalLibraries/../SharedLibraries/libxslt/lib/libxslt.1.dylib (compatibility version 3.0.0, current version 3.26.0) /Users/dev/dev/ExternalLibraries/../SharedLibraries/libxslt/lib/libexslt.0.dylib (compatibility version 9.0.0, current version 9.15.0) /Users/dev/dev/ExternalLibraries/yaml-cpp-0.2.5/build/libyaml-cpp.0.2.dylib (compatibility version 0.2.0, current version 0.2.5) QtGui.framework/Versions/4/QtGui (compatibility version 4.7.0, current version 4.7.0) QtCore.framework/Versions/4/QtCore (compatibility version 4.7.0, current version 4.7.0) /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.9.0) /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 625.0.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.0)
Output from “otool” is simmilar to linux tool “ldd”.
The Mac Deployment Tool
Because manual copying and configuring all shared libraries to our application could be difficult, Qt have deployment tool which do all work for us. Tool is called “macdeployqt” and can be found in /Developer/Tools/Qt/macdeployqt.
/Developer/Tools/Qt/macdeployqt ./GeneratedFilesMacOs/Debug/Test1.app
Note: Every time when you call macdeployqt tool, project have to be build from scratch. But is sufficient when whole result directory is removed and linked again:
rm -rf ./GeneratedFilesMacOs/Debug/Test1.app/ make