I want to create a custom framework with Qt. I am able to create the framework itself, but Qt fails to find the framework when run:
dyld: Library not loaded: QSettingsDialog.framework/Versions/0/QSettingsDialog
Referenced from: /Users/sky/QtProjects/build-QSettingsDialog-Desktop_Qt_5_7_0_clang_64bit-Debug/Examples/SimpleExample/SimpleExample.app/Contents/MacOS/SimpleExample
Reason: image not found
The reason is simple: The binary does not know where to look for the framework.
I used otool on the binary and saw this:
otool -L Examples/SimpleExample/SimpleExample.app/Contents/MacOS/SimpleExample
Examples/SimpleExample/SimpleExample.app/Contents/MacOS/SimpleExample:
QSettingsDialog.framework/Versions/0/QSettingsDialog (compatibility version 0.1.0, current version 0.1.2)
#rpath/QtWidgets.framework/Versions/5/QtWidgets (compatibility version 5.7.0, current version 5.7.0)
#rpath/QtGui.framework/Versions/5/QtGui (compatibility version 5.7.0, current version 5.7.0)
#rpath/QtCore.framework/Versions/5/QtCore (compatibility version 5.7.0, current version 5.7.0)
/System/Library/Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.1.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)
So, my question is as follows (For more details check the stuff below):
How can tell qmake to set the path for my library to:
#rpath/QSettingsDialog.framework/Versions/0/QSettingsDialog (compatibility version 0.1.0, current version 0.1.2)
Is there even a way to do this with qmake? I do know how to change this with the install_name_tool, but I would like to add it to the .pro file directly.
What I did so far:
I modified my pro file to change to rpath of the binary to include the path where the library is located at build-time:
otool -l Examples/SimpleExample/SimpleExample.app/Contents/MacOS/SimpleExample
Load command 22
cmd LC_RPATH
cmdsize 136
path /Users/sky/QtProjects/build-QSettingsDialog-Desktop_Qt_5_7_0_clang_64bit-Debug/Examples/SimpleExample/../../QSettingsDialog (offset 12)
Load command 23
cmd LC_RPATH
cmdsize 48
path /Users/sky/Qt/5.7/clang_64/lib (offset 12)
This way I can simply modify the rpath for a release without having to use the install_name_tool. However, for this to work, I need to change the first line to:
#rpath/QSettingsDialog.framework/Versions/0/QSettingsDialog (compatibility version 0.1.0, current version 0.1.2)
In my pro file for the application, i specified the following:
mac {
QMAKE_LFLAGS += -F$$OUT_PWD/../../QSettingsDialog/
QMAKE_LFLAGS += '-Wl,-rpath,\'$$OUT_PWD/../../QSettingsDialog\''
LIBS += -F$$OUT_PWD/../../QSettingsDialog/ -framework QSettingsDialog
}
The last missing piece is how to add the #rpath/. Thanks for your help.
Thanks to the links in the comment of #peppe, I was able to solve the problem:
I had to add
QMAKE_LFLAGS_SONAME = -Wl,-install_name,#rpath/
to the libraries pro file. This way Qt automatically uses #rpath/QSettingsDialog.framework/Versions/0/QSettingsDialog when creating the reference to the framework.
Related
I got a cpp game client like this in macOS:
$ otool -L ./XXXGameClient
./XXXGameClient:
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.50.4)
#rpath/SDL2.framework/Versions/A/SDL2 (compatibility version 1.0.0, current version 8.0.0)
/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 22.0.0)
#rpath/SDL2_image.framework/Versions/A/SDL2_image (compatibility version 1.0.0, current version 3.1.0)
#rpath/SDL2_mixer.framework/Versions/A/SDL2_mixer (compatibility version 1.0.0, current version 1.1.0)
#rpath/SDL2_ttf.framework/Versions/A/SDL2_ttf (compatibility version 15.0.0, current version 15.0.0)
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11)
/usr/local/opt/libpng/lib/libpng16.16.dylib (compatibility version 52.0.0, current version 52.0.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.0)
#rpath/libclang_rt.asan_osx_dynamic.dylib (compatibility version 0.0.0, current version 0.0.0)
The game client have dependency of libpng with a full path, i want to distribute the libpng binary to the executable directory and the it load the lib correctly, just like the SDL2 do with RPATH feature.
How could I do it?
Is there a way to specify the shared library path from CMakeLists.txt?
I want to make an executable which uses OpenCV but I don't want the final user to install OpenCV. Instead I would like to deliver a folder containing my executable and the shared libraries it needs. The final structure should be something like
Delivery
MyApp
OpenCV (folder containing opencv dylibs)
In the end MyApp should search for the shared libs in OpenCV folder.
I tried to use the info from https://cmake.org/Wiki/CMake_RPATH_handling but for some reason I don't seem to understand what i really have to do to achieve what I want.
I tried to set CMAKE_INSTALL_RPATH to #loader_path or #executable_path but don't see any change. It still searches for opencv libs in /lib folder.
Running otool -L MyApp results in:
lib/libopencv_imgproc.3.1.dylib (compatibility version 3.1.0, current version 3.1.0)
lib/libopencv_imgcodecs.3.1.dylib (compatibility version 3.1.0, current version 3.1.0)
lib/libopencv_highgui.3.1.dylib (compatibility version 3.1.0, current version 3.1.0)
lib/libopencv_core.3.1.dylib (compatibility version 3.1.0, current version 3.1.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.1.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)
I finished my mac app using Xcode and Qt. Now I would like to prepare it for deployment to other macs. Inorder to do that I utilized macdeployqt.
I just created an app bundle with macdeployqt. However some of the libraries are missing. I attempted to follow [this][1] answer. Turns out I need to copy the missing dylib from my computer to the .app and then run install name tool. I have not gotten to the install-name tool yet as I am confused as to use -id or -change with it especially in my current scenario. Do I even need to use it ? Here is what I did so far.
Step 1: Running macdeployqt - this is a program that comes with Qt and embeds the necessary requirements of qt into the app.
> /Users/Guest/Qt/5.5/clang_64/bin/macdeployqt project2.app
Step 2: I then decided to run otool on the actual generated app binary
> pwd
/Users/Guest/project_XCODE/bin/Release/project2.app/Contents/MacOS
> otool -L project2
project2:
#rpath/libcreatecore_rt.dylib (compatibility version 0.0.0, current version 0.0.0)
#rpath/QtQuick.framework/Versions/5/QtQuick (compatibility version 5.5.0, current version 5.5.1)
#rpath/QtConcurrent.framework/Versions/5/QtConcurrent (compatibility version 5.5.0, current version 5.5.1)
#rpath/QtSvg.framework/Versions/5/QtSvg (compatibility version 5.5.0, current version 5.5.1)
/System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
#executable_path/../Frameworks/libosg.141.dylib (compatibility version 141.0.0, current version 3.5.1)
#executable_path/../Frameworks/libosgDB.141.dylib (compatibility version 141.0.0, current version 3.5.1)
#executable_path/../Frameworks/libosgGA.141.dylib (compatibility version 141.0.0, current version 3.5.1)
#executable_path/../Frameworks/libosgUtil.141.dylib (compatibility version 141.0.0, current version 3.5.1)
#executable_path/../Frameworks/libosgViewer.141.dylib (compatibility version 141.0.0, current version 3.5.1)
#executable_path/../Frameworks/libosgManipulator.141.dylib (compatibility version 141.0.0, current version 3.5.1)
#executable_path/../Frameworks/libOpenThreads.20.dylib (compatibility version 20.0.0, current version 3.3.0)
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)
/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 22.0.0)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1256.14.0)
/usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
#rpath/libtbb.dylib (compatibility version 0.0.0, current version 0.0.0)
#rpath/libtbb_debug.dylib (compatibility version 0.0.0, current version 0.0.0)
#rpath/libtbbmalloc_debug.dylib (compatibility version 0.0.0, current version 0.0.0)
#rpath/libtbbmalloc_proxy.dylib (compatibility version 0.0.0, current version 0.0.0)
#rpath/libtbbmalloc_proxy_debug.dylib (compatibility version 0.0.0, current version 0.0.0)
#rpath/libtbb_preview.dylib (compatibility version 0.0.0, current version 0.0.0)
#rpath/libtbb_preview_debug.dylib (compatibility version 0.0.0, current version 0.0.0)
#rpath/libquazip.1.dylib (compatibility version 1.0.0, current version 1.0.0)
#executable_path/../Frameworks/libprotobuf.9.dylib (compatibility version 10.0.0, current version 10.1.0)
#rpath/QtQml.framework/Versions/5/QtQml (compatibility version 5.5.0, current version 5.5.1)
#rpath/QtNetwork.framework/Versions/5/QtNetwork (compatibility version 5.5.0, current version 5.5.1)
#rpath/QtWidgets.framework/Versions/5/QtWidgets (compatibility version 5.5.0, current version 5.5.1)
#rpath/QtGui.framework/Versions/5/QtGui (compatibility version 5.5.0, current version 5.5.1)
#rpath/QtCore.framework/Versions/5/QtCore (compatibility version 5.5.0, current version 5.5.1)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.1.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)
Step 3:
However I noticed that my project2.app/Contents/Frameworks does not have those libraries inside them. So I decided to copy them manually.
cp /usr/local/lib/libosg.141.dylib project2.app/Contents/Frameworks/libosg.141.dylib
cp /usr/local/lib/libosgDB.141.dylib project2.app/Contents/Frameworks/libosgDB.141.dylib
cp /usr/local/lib/libosgGA.141.dylib project2.app/Contents/Frameworks/libosgGA.141.dylib
cp /usr/local/lib/libosgUtil.141.dylib project2.app/Contents/Frameworks/libosgUtil.141.dylib
cp /usr/local/lib/libosgViewer.141.dylib project2.app/Contents/Frameworks/libosgViewer.141.dylib
cp /usr/local/lib/libosgManipulator.141.dylib project2.app/Contents/Frameworks/libosgManipulator.141.dylib
cp /usr/local/lib/libOpenThreads.20.dylib project2.app/Contents/Frameworks/libOpenThreads.20.dylib
Could you tell me what my next steps should be after copying those files ?
This is the output that I get when I attempt to run the app on another computer without using install_name_tool
Dyld Error Message:
Library not loaded: libosgUtil.141.dylib
Referenced from: /Users/one/Desktop/project2.app/Contents/Frameworks/libosgDB.141.dylib
Reason: image not found
Binary Images:
0x7fff6c436000 - 0x7fff6c46c837 dyld (353.2.1) <65DCCB06-339C-3E25-9702-600A28291D0E> /usr/lib/dyld
Update:
After some struggling I decided to do the following
install_name_tool -change libosg.141.dylib #executable_path/../Frameworks/libosg.141.dylib /Users/Guest/project_XCODE/bin/Release/project2.app/Contents/MacOS/project2
install_name_tool -change libosgDB.141.dylib #executable_path/../Frameworks/libosgDB.141.dylib /Users/Guest/project_XCODE/bin/Release/project2.app/Contents/MacOS/project2
install_name_tool -change libosgGA.141.dylib #executable_path/../Frameworks/libosgGA.141.dylib /Users/Guest/project_XCODE/bin/Release/project2.app/Contents/MacOS/project2
install_name_tool -change libosgUtil.141.dylib #executable_path/../Frameworks/libosgUtil.141.dylib /Users/Guest/project_XCODE/bin/Release/project2.app/Contents/MacOS/project2
install_name_tool -change libosgViewer.141.dylib #executable_path/../Frameworks/libosgViewer.141.dylib /Users/Guest/project_XCODE/bin/Release/project2.app/Contents/MacOS/project2
install_name_tool -change libosgManipulator.141.dylib #executable_path/../Frameworks/libosgManipulator.141.dylib /Users/Guest/project_XCODE/bin/Release/project2.app/Contents/MacOS/project2
install_name_tool -change libOpenThreads.20.dylib #executable_path/../Frameworks/libOpenThreads.20.dylib /Users/Guest/project_XCODE/bin/Release/project2.app/Contents/MacOS/project2
That did not seem to solve the problem as when I did this to one of the libraries that I just had added.
otool -L libosgDB.141.dylib
libosgDB.141.dylib:
#executable_path/../Frameworks/libosgDB.141.dylib (compatibility version 141.0.0, current version 3.5.1)
libosgUtil.141.dylib (compatibility version 141.0.0, current version 3.5.1) <-----!!!Why did this not change!!!!!
/System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 157.0.0)
/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 22.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)
/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
libosg.141.dylib (compatibility version 141.0.0, current version 3.5.1) <-----!!!Why did this not change!!!!!
libOpenThreads.20.dylib (compatibility version 20.0.0, current version 3.3.0)<-----!!!Why did this not change!!!!!
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.1.0)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1256.14.0)
/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1256.1.0)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
I am still not getting paths for the libraries libOpenThreads.20.dylib , libosgUtil.141.dylib and libosg.141.dylib any suggestions would be more than welcome.
libosg.141.dylib is a dylib that you're including in your built app.
You should actually look in your app's binary... that is:
otool -L /Users/Guest/project_XCODE/bin/Release/project2.app/Contents/MacOS/project2
As for resetting the path of the library to point to "#executable_path/../Frameworks/libosg.141.dylib" instead of the dylib in "/usr/local/lib", try doing this:
install_name_tool -change libosg.141.dylib #executable_path/../Frameworks/libosg.141.dylib /Users/Guest/project_XCODE/bin/Release/project2.app/Contents/MacOS/project2
I am having problems packaging my Qt app for Mac OS X using macdeployqt.
On my Mac, I have Qt5 installed on ~/Qt5.1.0/5.1.0/clang_64 (this is where the bin/ and lib/ folder resides)
I have a Qt application called "renamer" on ~/Documents/QtProjects/renamer/.
Using Qt Creator, I have built the release version of my application on ~/Documents/QtProjects/build-renamer-Desktop_Qt_5_1_0_clang_64bit-Release.
So the first thing I did was run otool on my application:
$ cd ~/Documents/QtProjects/build-renamer-Desktop_Qt_5_1_0_clang_64bit-Release
$ otool -L renamer.app/Contents/MacOS/renamer
renamer.app/Contents/MacOS/renamer:
/Users/paul/Qt5.1.0//5.1.0/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets (compatibility version 5.1.0, current version 5.1.0)
/Users/paul/Qt5.1.0//5.1.0/clang_64/lib/QtGui.framework/Versions/5/QtGui (compatibility version 5.1.0, current version 5.1.0)
/Users/paul/Qt5.1.0//5.1.0/clang_64/lib/QtCore.framework/Versions/5/QtCore (compatibility version 5.1.0, current version 5.1.0)
/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 56.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)
I have manually corrected the broken paths using install_name_tool:
$ cd ~/Documents/QtProjects/build-renamer-Desktop_Qt_5_1_0_clang_64bit-Release
$ install_name_tool -change /Users/paul/Qt5.1.0//5.1.0/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets /Users/paul/Qt5.1.0/5.1.0/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets renamer.app/Contents/MacOS/renamer
$ install_name_tool -change /Users/paul/Qt5.1.0//5.1.0/clang_64/lib/QtGui.framework/Versions/5/QtGui /Users/paul/Qt5.1.0/5.1.0/clang_64/lib/QtGui.framework/Versions/5/QtGui renamer.app/Contents/MacOS/renamer
$ install_name_tool -change /Users/paul/Qt5.1.0//5.1.0/clang_64/lib/QtCore.framework/Versions/5/QtCore /Users/paul/Qt5.1.0/5.1.0/clang_64/lib/QtCore.framework/Versions/5/QtCore renamer.app/Contents/MacOS/renamer
$ otool -L renamer.app/Contents/MacOS/renamer
renamer.app/Contents/MacOS/renamer:
/Users/paul/Qt5.1.0/5.1.0/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets (compatibility version 5.1.0, current version 5.1.0)
/Users/paul/Qt5.1.0/5.1.0/clang_64/lib/QtGui.framework/Versions/5/QtGui (compatibility version 5.1.0, current version 5.1.0)
/Users/paul/Qt5.1.0/5.1.0/clang_64/lib/QtCore.framework/Versions/5/QtCore (compatibility version 5.1.0, current version 5.1.0)
/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 56.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)
I have added /bin to my PATH and then called macdeployqt from my project directory.
$ cd ~/Documents/QtProjects/build-renamer-Desktop_Qt_5_1_0_clang_64bit-Release
$ sudo macdeployqt renamer.app
$ otool -L renamer.app/Contents/MacOS/renamer
renamer.app/Contents/MacOS/renamer:
#executable_path/../Frameworks/QtWidgets.framework/Versions/5/QtWidgets (compatibility version 5.1.0, current version 5.1.0)
#executable_path/../Frameworks/QtGui.framework/Versions/5/QtGui (compatibility version 5.1.0, current version 5.1.0)
#executable_path/../Frameworks/QtCore.framework/Versions/5/QtCore (compatibility version 5.1.0, current version 5.1.0)
/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 56.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)
However, when I rename/remove the installed Qt libraries and run the application, I get an error indicating that the Qt libraries cannot be found within my app bundle. Any suggestions?
I just have build Qt5 on Mac 10.8 from git as per this article
Everything went fine, I git make, make install and now I have Qt5 installed into /usr/local/Qt-5.1.1
The problem is that Assistant.app won't run - it crashes on startup. I ran otool (output is below) and found that QWebKit and QWebKitWidgets are linked with absolute path pointing to the build location which is no longer valida since I cleaned after installing. Is it a bug or something that I missed?
ak128#localhost:qt5 [git:stable+?]$ otool -L /usr/local/Qt-5.1.1/bin/Assistant.app/Contents/MacOS/Assistant
/usr/local/Qt-5.1.1/bin/Assistant.app/Contents/MacOS/Assistant:
/Users/ak128/Developer/cpp/qt5/qtwebkit/lib/QtWebKitWidgets.framework/Versions/5/QtWebKitWidgets (compatibility version 5.1.0, current version 5.1.1)
/usr/local/Qt-5.1.1/lib/QtQuick.framework/Versions/5/QtQuick (compatibility version 5.1.0, current version 5.1.1)
/usr/local/Qt-5.1.1/lib/QtQml.framework/Versions/5/QtQml (compatibility version 5.1.0, current version 5.1.1)
/usr/local/Qt-5.1.1/lib/QtNetwork.framework/Versions/5/QtNetwork (compatibility version 5.1.0, current version 5.1.1)
/usr/local/Qt-5.1.1/lib/QtCore.framework/Versions/5/QtCore (compatibility version 5.1.0, current version 5.1.1)
/usr/local/Qt-5.1.1/lib/QtGui.framework/Versions/5/QtGui (compatibility version 5.1.0, current version 5.1.1)
/usr/local/Qt-5.1.1/lib/QtOpenGL.framework/Versions/5/QtOpenGL (compatibility version 5.1.0, current version 5.1.1)
/usr/local/Qt-5.1.1/lib/QtWidgets.framework/Versions/5/QtWidgets (compatibility version 5.1.0, current version 5.1.1)
/usr/local/Qt-5.1.1/lib/QtPrintSupport.framework/Versions/5/QtPrintSupport (compatibility version 5.1.0, current version 5.1.1)
/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 19.0.0)
/Users/ak128/Developer/cpp/qt5/qtwebkit/lib/QtWebKit.framework/Versions/5/QtWebKit (compatibility version 5.1.0, current version 5.1.1)
/usr/local/Qt-5.1.1/lib/QtSql.framework/Versions/5/QtSql (compatibility version 5.1.0, current version 5.1.1)
/usr/local/Qt-5.1.1/lib/QtSensors.framework/Versions/5/QtSensors (compatibility version 5.1.0, current version 5.1.1)
/usr/local/Qt-5.1.1/lib/QtHelp.framework/Versions/5/QtHelp (compatibility version 5.1.0, current version 5.1.1)
/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 65.1.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)
This seems like a genuine bug, see https://bugreports.qt-project.org/browse/QTBUG-32417
As a workaround, you can set the DYLD_FRAMEWORK_PATH to point to your installation directory, in your case that would be:
export DYLD_FRAMEWORK_PATH=/usr/local/Qt-5.1.1/lib
Then, you should be able to run assistant from command line, e.g.
open Assistant.app