[vtkusers] How to fix Mac OS X problem of applications not being able to dine dyld libraries

Michael Jackson mike.jackson at bluequartz.net
Thu Oct 16 08:18:28 EDT 2008


This is well know and well understood. You can build VTK with RPATH on  
BUT you will have to run VTK from the BUILD tree. This will tell the  
build system to add the "install_name" argument to the linker and all  
should be fine for you after that.

Next,
   There is a new module in the latest CMake called "BundleUtilities"  
that will take care of all the install_name_tool changing stuff. I  
wrote a wiki entry for it yesterday. http://www.cmake.org/Wiki/BundleUtilitiesExample

This is used in the ParaView3 CVS to construct the stand alone  
ParaView3.app bundle and seems to work very well.

Qt also has an experimental tool called "DeployQt" on their blog site  
somewhere but that is more Qt related and does not take into account  
other libraries so isn't really that good yet.

I wrote a script for the MacPorts people that ran through all the vtk  
libraries and changed all the install_name properties of all the  
libraries for their build systems.

I also wrote an earlier script for my own Qt/VTK based applications  
that would do all the necessary updates recursively for the executable  
and all affected libraries (non-system).

Let me know if you are interested in any of it or need some help with  
any of the cmake stuff.

What is really happening is that vtk is defaulted to building without  
_any_ install_name in the libraries. You can export the  
DYLD_LIBRARY_PATH variable and then launch Xcode from the command line  
to pick up the new variable. This is a quick fix but not a good  
solution for deploying an application.  Getting the install_name  
correct in the first place is the best fix, followed by some sort of  
tool to update the install_name when building a package.
_________________________________________________________
Mike Jackson                  mike.jackson at bluequartz.net
BlueQuartz Software                    www.bluequartz.net
Principal Software Engineer                  Dayton, Ohio

On Oct 16, 2008, at 7:59 AM, Elvis Dowson wrote:

> Hi,
>           When I compile VTK shared libraries and use them with  
> Xcode, I can launch them fine from the command terminal. However,  
> when I try to launch it from Xcode, it exits with reason 5. If I try  
> to launch the same application package using Finder, it generates  
> and error message saying for example:
>
> Dyld Error Message:
>   Library not loaded: libQVTK.5.3.dylib
>   Referenced from: /Users/elvis/Project/C4I/Source/cxx/ 
> QVTKQtWidgetInOpenGLSceneTest/build/Debug/ 
> QVTKQtWidgetInOpenGLSceneTest.app/Contents/MacOS/ 
> QVTKQtWidgetInOpenGLSceneTest
>   Reason: image not found
>
> This is a known problem and the solution is to run install_tool_name  
> to fix the patch to the dynamic link libraries.
>
> However, now there is another problem. I've fixed all the paths to  
> the dynamic link libraries, but those libraries themselves refer to  
> other link libraries, so I'm a bit lost what to do.
>
> Dyld Error Message:
>   Library not loaded: libvtkQtChart.5.3.dylib
>   Referenced from: /Users/elvis/Project/C4I/Source/cxx/ 
> QVTKQtWidgetInOpenGLSceneTest/build/Debug/ 
> QVTKQtWidgetInOpenGLSceneTest.app/Contents/MacOS/../Frameworks/ 
> libQVTK.5.3.dylib
>   Reason: image not found
>
>  It's really messy having to deal with this. This situation is also  
> preventing me from using Xcode to debug my Qt/VTK program, since it  
> keeps crashing because it can't find the dynamic link libraries,  
> when I try to launch it from Xcode.
>
> Here is a small work in progress for an Xcode build script to fix  
> the correct path to the dynamic link libraries from the application  
> executable point of view. What I need now is a solution to also  
> update the references to the numerous dynamic link libraries that  
> the vtk dynamic link libraries themselves refer to !! (groan!!) :-)
>
> Best regards,
>
> Elvis Dowson
>
>
> Technote Xcode-3.1.1-001: How to fix dyld library not loaded error  
> message
>
> Procedure
>
> Step 01: Check the existing paths for the dynamic link libraries  
> using the otool
>
> otool -L QVTKQtWidgetInOpenGLSceneTest.app/Contents/MacOS/ 
> QVTKQtWidgetInOpenGLSceneTest
>
> QVTKQtWidgetInOpenGLSceneTest.app/Contents/MacOS/ 
> QVTKQtWidgetInOpenGLSceneTest:
> 	/usr/local/lib/libpng12.0.dylib (compatibility version 32.0.0,  
> current version 32.0.0)
> 	/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version  
> 1.2.3)
> 	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current  
> version 111.1.1)
> 	libQVTK.5.3.dylib (compatibility version 0.0.0, current version  
> 0.0.0)
> 	libvtkHybrid.5.3.dylib (compatibility version 0.0.0, current  
> version 0.0.0)
> 	libvtkIO.5.3.dylib (compatibility version 0.0.0, current version  
> 0.0.0)
> 	libvtkImaging.5.3.dylib (compatibility version 0.0.0, current  
> version 0.0.0)
> 	libvtkRendering.5.3.dylib (compatibility version 0.0.0, current  
> version 0.0.0)
> 	libvtkWidgets.5.3.dylib (compatibility version 0.0.0, current  
> version 0.0.0)
> 	libvtkGraphics.5.3.dylib (compatibility version 0.0.0, current  
> version 0.0.0)
> 	libvtkFiltering.5.3.dylib (compatibility version 0.0.0, current  
> version 0.0.0)
> 	libvtkGenericFiltering.5.3.dylib (compatibility version 0.0.0,  
> current version 0.0.0)
> 	libvtkCommon.5.3.dylib (compatibility version 0.0.0, current  
> version 0.0.0)
> 	libvtkexoIIc.5.3.dylib (compatibility version 0.0.0, current  
> version 0.0.0)
> 	libvtkexpat.5.3.dylib (compatibility version 0.0.0, current version  
> 0.0.0)
> 	libvtkftgl.5.3.dylib (compatibility version 0.0.0, current version  
> 0.0.0)
> 	libvtkjpeg.5.3.dylib (compatibility version 0.0.0, current version  
> 0.0.0)
> 	libvtkpng.5.3.dylib (compatibility version 0.0.0, current version  
> 0.0.0)
> 	libvtktiff.5.3.dylib (compatibility version 0.0.0, current version  
> 0.0.0)
> 	libvtksys.5.3.dylib (compatibility version 0.0.0, current version  
> 0.0.0)
> 	libvtkzlib.5.3.dylib (compatibility version 0.0.0, current version  
> 0.0.0)
> 	libvtkfreetype.5.3.dylib (compatibility version 0.0.0, current  
> version 0.0.0)
> 	/Developer/Applications/Qt-4.4.3/lib/QtOpenGL.framework/Versions/4/ 
> QtOpenGL (compatibility version 4.4.0, current version 4.4.3)
> 	/Developer/Applications/Qt-4.4.3/lib/QtGui.framework/Versions/4/ 
> QtGui (compatibility version 4.4.0, current version 4.4.3)
> 	/System/Library/Frameworks/Carbon.framework/Versions/A/Carbon  
> (compatibility version 2.0.0, current version 136.0.0)
> 	/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit  
> (compatibility version 45.0.0, current version 949.35.0)
> 	/Developer/Applications/Qt-4.4.3/lib/QtCore.framework/Versions/4/ 
> QtCore (compatibility version 4.4.0, current version 4.4.3)
> 	/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 7.4.0)
> 	/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current  
> version 1.0.0)
>
>
> Step 02: Create a Run Build script
>
> In Xcode, right click on the target and select Add->New Build Phase- 
> >New Run Script Build Phase, and enter the follow script
>
> # Declare script variables
> export VTK_LIB_DIR=/Users/elvis/Tool/vtk-5.x/install/carbon-shared/ 
> lib/vtk-5.3
> export NEWLIBPATH="@loader_path/../Frameworks"
>
> # Declare list of library targets
> export TARGETS="libQVTK.5.3.dylib libvtkHybrid.5.3.dylib libvtkIO. 
> 5.3.dylib libvtkImaging.5.3.dylib libvtkRendering.5.3.dylib  
> libvtkWidgets.5.3.dylib libvtkGraphics.5.3.dylib libvtkFiltering. 
> 5.3.dylib libvtkGenericFiltering.5.3.dylib libvtkCommon.5.3.dylib  
> libvtkexoIIc.5.3.dylib libvtkexpat.5.3.dylib libvtkftgl.5.3.dylib  
> libvtkjpeg.5.3.dylib libvtkpng.5.3.dylib libvtktiff.5.3.dylib  
> libvtksys.5.3.dylib libvtkzlib.5.3.dylib libvtkfreetype.5.3.dylib"
>
> # Create folders in the application package
> mkdir "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/Frameworks"
>
> # Change the reference to the dynamic link libraries in a loop for  
> all listed library targets
> for TARGET in ${TARGETS} ; do
> cp -f $VTK_LIB_DIR/${TARGET} "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/ 
> Contents/Frameworks/${TARGET}"
> install_name_tool -change ${TARGET} @loader_path/../Frameworks/$ 
> {TARGET} "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/MacOS/ 
> $PRODUCT_NAME"
> done
>
> Step 03: Check the updates paths for the dynamic link libraries  
> using the otool
>
> otool -L QVTKQtWidgetInOpenGLSceneTest.app/Contents/MacOS/ 
> QVTKQtWidgetInOpenGLSceneTest
>
> QVTKQtWidgetInOpenGLSceneTest.app/Contents/MacOS/ 
> QVTKQtWidgetInOpenGLSceneTest:
> 	/usr/local/lib/libpng12.0.dylib (compatibility version 32.0.0,  
> current version 32.0.0)
> 	/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version  
> 1.2.3)
> 	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current  
> version 111.0.0)
> 	@loader_path/../Frameworks/libQVTK.5.3.dylib (compatibility version  
> 0.0.0, current version 0.0.0)
> 	@loader_path/../Frameworks/libvtkHybrid.5.3.dylib (compatibility  
> version 0.0.0, current version 0.0.0)
> 	@loader_path/../Frameworks/libvtkIO.5.3.dylib (compatibility  
> version 0.0.0, current version 0.0.0)
> 	@loader_path/../Frameworks/libvtkImaging.5.3.dylib (compatibility  
> version 0.0.0, current version 0.0.0)
> 	@loader_path/../Frameworks/libvtkRendering.5.3.dylib (compatibility  
> version 0.0.0, current version 0.0.0)
> 	@loader_path/../Frameworks/libvtkWidgets.5.3.dylib (compatibility  
> version 0.0.0, current version 0.0.0)
> 	@loader_path/../Frameworks/libvtkGraphics.5.3.dylib (compatibility  
> version 0.0.0, current version 0.0.0)
> 	@loader_path/../Frameworks/libvtkFiltering.5.3.dylib (compatibility  
> version 0.0.0, current version 0.0.0)
> 	@loader_path/../Frameworks/libvtkGenericFiltering.5.3.dylib  
> (compatibility version 0.0.0, current version 0.0.0)
> 	@loader_path/../Frameworks/libvtkCommon.5.3.dylib (compatibility  
> version 0.0.0, current version 0.0.0)
> 	@loader_path/../Frameworks/libvtkexoIIc.5.3.dylib (compatibility  
> version 0.0.0, current version 0.0.0)
> 	@loader_path/../Frameworks/libvtkexpat.5.3.dylib (compatibility  
> version 0.0.0, current version 0.0.0)
> 	@loader_path/../Frameworks/libvtkftgl.5.3.dylib (compatibility  
> version 0.0.0, current version 0.0.0)
> 	@loader_path/../Frameworks/libvtkjpeg.5.3.dylib (compatibility  
> version 0.0.0, current version 0.0.0)
> 	@loader_path/../Frameworks/libvtkpng.5.3.dylib (compatibility  
> version 0.0.0, current version 0.0.0)
> 	@loader_path/../Frameworks/libvtktiff.5.3.dylib (compatibility  
> version 0.0.0, current version 0.0.0)
> 	@loader_path/../Frameworks/libvtksys.5.3.dylib (compatibility  
> version 0.0.0, current version 0.0.0)
> 	@loader_path/../Frameworks/libvtkzlib.5.3.dylib (compatibility  
> version 0.0.0, current version 0.0.0)
> 	@loader_path/../Frameworks/libvtkfreetype.5.3.dylib (compatibility  
> version 0.0.0, current version 0.0.0)
> 	/Developer/Applications/Qt-4.4.3/lib/QtOpenGL.framework/Versions/4/ 
> QtOpenGL (compatibility version 4.4.0, current version 4.4.3)
> 	/Developer/Applications/Qt-4.4.3/lib/QtGui.framework/Versions/4/ 
> QtGui (compatibility version 4.4.0, current version 4.4.3)
> 	/System/Library/Frameworks/Carbon.framework/Versions/A/Carbon  
> (compatibility version 2.0.0, current version 136.0.0)
> 	/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit  
> (compatibility version 45.0.0, current version 949.0.0)
> 	/Developer/Applications/Qt-4.4.3/lib/QtCore.framework/Versions/4/ 
> QtCore (compatibility version 4.4.0, current version 4.4.3)
> 	/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 7.4.0)
> 	/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current  
> version 1.0.0)
>
>
> Related Links
>
> 01. How To use Dynamic Libraries in Xcode 3.1 (using FMOD) -  
> BrockWoolf.com
>
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers




More information about the vtkusers mailing list