[CMake] Cmake MacOSX Question

Hans J. Johnson johnsonhj at healthcare.uiowa.edu
Fri Jun 23 10:46:30 EDT 2006


Cmake Experts,

I am running into a problem with static libraries and conflicting frameworks
on MacOSX.  I need to statically build my own version of tcl and tk with X11
bindings and link it to my application.  The problem is that the linker is
preferring to bind to the Tcl.framework and Tk.Framework dynamic libraries
instead of the ones that I specify.


----- Notice the explicitly specified link directories -----
[hjohnson]$ /usr/bin/c++    -bind_at_load  -O2  -ftemplate-depth-50
-no-cpp-precomp -Wno-long-double  -ftemplate-depth-50 -no-cpp-precomp
-Wno-long-double -DNO_ITK_TCL -O3 -DNDEBUG -headerpad_max_install_names
-fPIC    "CMakeFiles/brains2.dir/tkAppInit.o"
"CMakeFiles/brains2.dir/tkInstallCommands.o"   -o ../bin/brains2
-L/scratch/hjohnson/src/brains2/MacOSX/FAST/src/lib/InsightToolkit -L.
-L/scratch/hjohnson/src/brains2/MacOSX/FAST/src/lib -L/usr/X11R6/lib
-L/sw/lib -lb2Utils -liplGUI -lb2Utils -liplKernel -lITKBasicFilters -lITKIO
-lITKNrrdIO -litkgdcm -litkjpeg12 -litkjpeg16 -litkopenjpeg -litkpng
-litktiff -litkjpeg8 -lITKSpatialObject -lITKNumerics -lITKMetaIO
-lITKDICOMParser -lITKEXPAT -lITKniftiio -lITKznz -litkzlib -lqHull
-liplAlgorithms -liplObject -lgts -liplHeader -liplPixelTable -liplUtils
-liplLogging -lITKCommon -litkvnl_inst -litkvnl_algo -litkvnl -litknetlib
-litkvcl -litksys -lpthread -lm -lgts -lglib -lgmodule -lgthread -ltcl8.4
-ltk8.4 -lforms -lformsGL -lm -lX11 -lXext -lXmu -lXpm -lGLU -lGL


----- A listing of the important libraries that are being missed -----
[hjohnson]$ ls /scratch/hjohnson/src/brains2/MacOSX/FAST/src/lib/libt[ck]*
/scratch/hjohnson/src/brains2/MacOSX/FAST/src/lib/libtcl8.4.a
/scratch/hjohnson/src/brains2/MacOSX/FAST/src/lib/libtk8.4.a
/scratch/hjohnson/src/brains2/MacOSX/FAST/src/lib/libtclstub8.4.a
/scratch/hjohnson/src/brains2/MacOSX/FAST/src/lib/libtkstub8.4.a

----- A listing of the libraries that were actually linked -----
[hjohnson]$ otool -L ../bin/brains2
../bin/brains2:
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current
version 88.1.5)
        /sw/lib/libglib-1.2.0.dylib (compatibility version 1.0.0, current
version 1.10.0)
        /sw/lib/libgmodule-1.2.0.dylib (compatibility version 1.0.0, current
version 1.10.0)
        /sw/lib/libgthread-1.2.0.dylib (compatibility version 1.0.0, current
version 1.10.0)
        /System/Library/Frameworks/Tcl.framework/Versions/8.4/Tcl
(compatibility version 8.4.0, current version 8.4.0)
        /System/Library/Frameworks/Tk.framework/Versions/8.4/Tk
(compatibility version 8.4.0, current version 8.4.0)
        /usr/X11R6/lib/libX11.6.dylib (compatibility version 6.2.0, current
version 6.2.0)
        /usr/X11R6/lib/libXext.6.dylib (compatibility version 6.4.0, current
version 6.4.0)
        /usr/X11R6/lib/libXmu.6.dylib (compatibility version 6.2.0, current
version 6.2.0)
        /usr/X11R6/lib/libXpm.4.dylib (compatibility version 4.11.0, current
version 4.11.0)
        /usr/X11R6/lib/libGLU.1.dylib (compatibility version 1.3.0, current
version 1.3.0)
        /usr/X11R6/lib/libGL.1.dylib (compatibility version 1.2.0, current
version 1.2.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)


==============
==============
==============
If I replace the -ltk8.4 and -ltcl8.4 compile options with the full paths to
the static libraries (i.e.
/scratch/hjohnson/src/brains2/MacOSX/FAST/src/lib/libtcl8.4.a), then the
exectuable works, and otool reports the proper libs.

I have also verified that the proper header files (i.e. Those from
/scratch/hjohnson/src/brains2/MacOSX/FAST/src/include ) are being included
during the object building phase.  This seems to be working just fine and
the frameworks are being avoided.

Any help would be greatly appreciated.

Thanks,
Hans
 



More information about the CMake mailing list