I fixed my own issue eventually. The problem was that all the dylibs with which the main executable was linked were referring to (for instance) QtOpenGL.Framework/Versions/4/OpenGL and it was taking that as a relative path from /Library/Frameworks rather than from the location of the dylib (which would have put it inside the bundle in the proper location). As a result, some parts of the program were referring to different libraries and so Qt had a different context (or something) there.
While there is probably a better way to solve this, I just added this to the deployment script to work around it temporarily:
# Get each dylib to point to the proper location for the Qt libraries -
# that is, inside the bundle, not into /Library/Frameworks.
PREFIX="@executable_path/../Frameworks/"
# (1) Get each dylib (files only - not symlinks) and get the
# main executable too.
find $DESTDIR/NLign3D.app/Contents/Frameworks -type f | egrep "\.dylib$" > /tmp/libs.txt
echo $DESTDIR/NLign3D.app/Contents/MacOS/NLign3D >> /tmp/libs.txt
cat /tmp/libs.txt |
while read LIBNAME
do
# (2) Find any reference to Qt libs that aren't
# via @executable_path/.. etc.
otool -L $LIBNAME |
sed -e "s/^[[:blank:]]*//g" |
egrep "^Qt" |
cut -d ' ' -f 1 |
while read LIBREF
do
# (3) Prefix these refs with $PREFIX so that the
# dylibs look inside the bundle for Qt, rather than
# in /Library/Frameworks.
NEWREF=$PREFIX$LIBREF
install_name_tool -change $LIBREF $NEWREF $LIBNAME
done
done
# Get each dylib to point to the proper location for the Qt libraries -
# that is, inside the bundle, not into /Library/Frameworks.
PREFIX="@executable_path/../Frameworks/"
# (1) Get each dylib (files only - not symlinks) and get the
# main executable too.
find $DESTDIR/NLign3D.app/Contents/Frameworks -type f | egrep "\.dylib$" > /tmp/libs.txt
echo $DESTDIR/NLign3D.app/Contents/MacOS/NLign3D >> /tmp/libs.txt
cat /tmp/libs.txt |
while read LIBNAME
do
# (2) Find any reference to Qt libs that aren't
# via @executable_path/.. etc.
otool -L $LIBNAME |
sed -e "s/^[[:blank:]]*//g" |
egrep "^Qt" |
cut -d ' ' -f 1 |
while read LIBREF
do
# (3) Prefix these refs with $PREFIX so that the
# dylibs look inside the bundle for Qt, rather than
# in /Library/Frameworks.
NEWREF=$PREFIX$LIBREF
install_name_tool -change $LIBREF $NEWREF $LIBNAME
done
done
To copy to clipboard, switch view to plain text mode
Bookmarks