[CMake] osx-10.5 ranlib vs ranlib -c vs libtool

Bob Tanner tanner at real-time.com
Fri Jun 5 18:37:11 EDT 2009


Ran into another issue with my netrek-server move to cmake.

Attempting to link with an internal library gives me a whole bunch of 
"non_lazy_ptr" linking errors:

Linking C executable trimscores
Undefined symbols:
  "_Cambot_out", referenced from:
      _Cambot_out$non_lazy_ptr in libnetrek.a(getpath.o)
  "_NoCount_File", referenced from:
      _NoCount_File$non_lazy_ptr in libnetrek.a(getpath.o)
  "_Global", referenced from:
      _Global$non_lazy_ptr in libnetrek.a(getpath.o)

Spent alot of time poking around google until I found this url:

http://software.intel.com/en-us/articles/intelr-fortran-compiler-for-mac-os-non_lazy_ptr-unresolved-references-from-linking/

Summary 

of the above url says that when you "ranlib" you really should "ranlib 
-c" and makes reference to the libtool manpage (more on this later).

If I 'ranlib -c ntserv/libnetrek.a' and make

$ make
<snip>
Linking C executable trimscores
[ 98%] Built target trimscores

Things work.

First question, how to I add "-c" to ranlib evocation?

I build libnetrek via the ADD_LIBRARY as noted below:

ADD_LIBRARY (netrek STATIC
	advertise.c
	alarm.c
	<snip>
	warning.c
)

Which generates this command line:

/usr/bin/ar cr libnetrek.a  CMakeFiles/netrek.dir/advertise.o 
CMakeFiles/netrek.
dir/alarm.o <snip>  CMakeFiles/netrek.dir/warning.o
/usr/bin/ranlib libnetrek.a

My gut tells me to change CMAKE_RANLIB but maybe a change the ADD_LIBRARY?



My research on ranlib lead me to libtool and the libtool manpage. On 
osx-10.5.7 (all I have access to) the libtool manpage states:

" Libtool with -static is intended to  replace  ar(5)  and  ranlib.   
For backward compatibility, ranlib is still available, and it supports 
universal files. "

To ultimately, the ADD_LIBRARY should be changed to libtool. Just 
passing that information along.

Thanks.


-- 
Bob Tanner <tanner at real-time.com>                  | Phone : (952 943-8700
http://www.real-time.com, Linux, OSX, VMware | Fax   : (952)943-8500
Key fingerprint = F785 DDFC CF94 7CE8 AA87 3A9D 3895 26F1 0DDB E378




More information about the CMake mailing list