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:
Qt Code:
  1. # Get each dylib to point to the proper location for the Qt libraries -
  2. # that is, inside the bundle, not into /Library/Frameworks.
  3. PREFIX="@executable_path/../Frameworks/"
  4. # (1) Get each dylib (files only - not symlinks) and get the
  5. # main executable too.
  6. find $DESTDIR/NLign3D.app/Contents/Frameworks -type f | egrep "\.dylib$" > /tmp/libs.txt
  7. echo $DESTDIR/NLign3D.app/Contents/MacOS/NLign3D >> /tmp/libs.txt
  8. cat /tmp/libs.txt |
  9. while read LIBNAME
  10. do
  11. # (2) Find any reference to Qt libs that aren't
  12. # via @executable_path/.. etc.
  13. otool -L $LIBNAME |
  14. sed -e "s/^[[:blank:]]*//g" |
  15. egrep "^Qt" |
  16. cut -d ' ' -f 1 |
  17. while read LIBREF
  18. do
  19. # (3) Prefix these refs with $PREFIX so that the
  20. # dylibs look inside the bundle for Qt, rather than
  21. # in /Library/Frameworks.
  22. NEWREF=$PREFIX$LIBREF
  23. install_name_tool -change $LIBREF $NEWREF $LIBNAME
  24. done
  25. done
To copy to clipboard, switch view to plain text mode