[CMake] Cmake MacOSX Question

Hans Johnson hans-johnson at uiowa.edu
Sat Jun 24 23:09:34 EDT 2006


Brad,

Thanks for all your suggestions. They put me onto the correct path to
figuring out what was going on.  Close inspection of the man page for ld on
MacOSX indicates why the strange behavior was occuring.

 

-search_paths_first
         By  default  when  the  -dynamic  flag is in effect, the -lx and
        -weak-lx  options  first  search  for  a  file   of   the   form
        `libx.dylib'  in each directory in the library search path, then
        a file of the form `libx.a'  is  searched  for  in  the  library
        search  paths.   This  option  changes  it  so that in each path
        `libx.dylib' is searched for then `libx.a' before the next  path
        in the library search path is searched.


Thanks,
Hans




On 6/23/06 12:49 PM, "Brad King" <brad.king at kitware.com> wrote:

> Hans J. Johnson wrote:
>> Here is the output.  I am still perplexed as to why the tcl and tk libraries
>> from the framework (or /usr/lib) are being included.
> [snip]
>>  /usr/libexec/gcc/powerpc-apple-darwin8/4.0.1/collect2 -dynamic -arch ppc
>> -bind_at_load -headerpad_max_install_names -macosx_version_min 10.3
>> -multiply_defined suppress -weak_reference_mismatches non-weak -o
>> ../bin/brains2 -lcrt1.o /usr/lib/gcc/powerpc-apple-darwin8/4.0.1/crt2.o
>> /usr/lib/gcc/powerpc-apple-darwin8/4.0.1/crt3.o
>> -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
>> -L/usr/lib/gcc/powerpc-apple-darwin8/4.0.1
>> -L/usr/lib/gcc/powerpc-apple-darwin8/4.0.1
>> -L/usr/lib/gcc/powerpc-apple-darwin8/4.0.1/../../..
> [snip]
>> -ltcl8.4 -ltk8.4
> 
> The libtcl8.4.so in /usr/lib is probably a symlink to the framework one.
>   I wonder if the current working directory of the collect2 process as
> started by gcc is /usr/lib, so that the -L. is picking up the files from
> there.  Try taking off the -L. from the command line of /usr/bin/c++.
> 
> Also note that the path
> -L/usr/lib/gcc/powerpc-apple-darwin8/4.0.1/../../.. is actually
> /usr/lib.  Perhaps the linker is searching backwards somehow?
> 
> Alternatively the linker could be searching the entire path for a shared
> library and then searching the entire path for a static library.  Since
> it finds libtcl8.4.so in /usr/lib it doesn't ever look for libtcl8.4.a.
>   Try changing TCL_LIBRARY to "-Wl,-Bstatic -ltcl8.4 -Wl,-Bdynamic".
> 
> -Brad



More information about the CMake mailing list