Diane Trout (alienghic) wrote,
Diane Trout

something to hate about OS X

Every platform has its own private circle of shared (or dynamic) library hell.

For some reason the developers of OS X decided that applications should have the full pathname to whatever shared libraries are in it embedded in the application binary. This might be useful from the standpoint of performance, and may make it less likely that you'll load the wrong library.

However it makes building an application that uses shared libraries nightmarish. One might ask, if shared libraries are so bad, why not statically link it? And that would be a good idea if I could figure out why a statically linked Qt application built on an OS X 10.4 machine doesn't run on a 10.3.9 machine.

I eventually pieced together enough from the Qt docs to properly bless my archive.
# This shell script is hereby placed into the public domain.
# Set all the stupid @executable_path variables on os x for a qt opengl application
# set QTDIR to the location of your qt library, and APP to the name of the application
export QTDIR=/usr/local/qt/4.1.0-shared
export APP=qtgl

for qt_lib in QtCore QtGui QtOpenGL; do
  mkdir -p ${APP}.app/Contents/Frameworks/${framework_dir}
  cp ${QTDIR}/lib/${framework} ${APP}.app/Contents/Frameworks/${framework}
  install_name_tool -id @executable_path/../Frameworks/${framework} \
  install_name_tool -change ${QTDIR}/lib/${framework} \
                            @executable_path/../Frameworks/${framework} \

install_name_tool -change \
     ${QTDIR}/lib/QtCore.framework/Versions/4.0/QtCore \
     @executable_path/../Frameworks/QtCore.framework/Versions/4.0/QtCore \
install_name_tool -change \
     ${QTDIR}/lib/QtCore.framework/Versions/4.0/QtCore \
     @executable_path/../Frameworks/QtCore.framework/Versions/4.0/QtCore \
install_name_tool -change \
     ${QTDIR}/lib/QtGui.framework/Versions/4.0/QtGui \
     @executable_path/../Frameworks/QtGui.framework/Versions/4.0/QtGui \

Though other than this setting the frameworks stuff Qt is nice, my application builds on linux, OS X, and windows without any problem.

  • Guild Wars 2

    I started playing Guild Wars 2, and am happy their questing system has broken with WoW's current quest design. As WoW grew they "simplified" and…

  • calendar.

    Its been a really long time since I tried to write. I keep meaning to roll my own blog software, but there's so many other things I should be doing.…

  • Building debian packages for mozilla's sync server

    I'm surprised this seems to have gotten valid debian packages with a minimum of fuss for a package where I couldn't find a recommended release…

  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded