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

Elvis Dowson elvis.dowson at mac.com
Thu Oct 16 07:59:20 EDT 2008


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


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20081016/bc172e8b/attachment.htm>


More information about the vtkusers mailing list