[CMake] Mac: libtool -static instead of ar + ranlib

James Bigler jamesbigler at gmail.com
Thu Jul 11 17:48:41 EDT 2013


Is there a way to use libtool -static instead of ar + ranlib?  I'm running
into some situations where ar + ranlib are generating errors where libtool
-static does not.

Basically I have a tool that generates object files (CUDA), but it can only
do so for a single architecture at a time.  If I build both a 32 bit and a
64 bit object and use g++ -shared to generate a shared library it warns,
but it doesn't error out (basically it runs the linker twice and whines
when encountering the object files for the other architecture and then
ignores them).  When I do something similar for a static library ar and
ranlib also warn, but ranlib returns an error code even though it actually
did something useful and the resulting binary is usable (perhaps returning
the error code is a bug in ranlib - I'm not sure).  libtool -static does
the right thing without warnings or errors, which is why I wanted to try to
use that.

If there doesn't exist a solution then I have a bunch of crazy code that
generates two libraries and uses lipo to put them together, but I was
hoping for a simpler solution (if one exists).

Note the documentation for libtool on OSX states, "Libtool with -static is
intended to replace ar(5) and ranlib", so I'm not crazy for wanting to use
this.

Thanks,
James
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20130711/dd9afc49/attachment.htm>


More information about the CMake mailing list