[CMake] Re: deprecated static libraries on Mac
Bill Hoffman
bill.hoffman at kitware.com
Fri Aug 10 14:08:40 EDT 2007
Brandon Van Every wrote:
> On 8/10/07, Bill Hoffman <bill.hoffman at kitware.com> wrote:
>
>> Brandon Van Every wrote:
>>
>>> http://developer.apple.com/qa/qa2001/qa1118.html
>>>
>>>
>> I am not sure this means static libraries are deprecated. It just
>> means that completely static
>> executables are not recommended. They want you to use the dynamic run
>> time libraries.
>> This is very similar to the MS compiler. However, your application can
>> use lots of static
>> libraries that contain your code.
>>
>
> The OS X linker will go out of its way to sabotage your code. If you
> have a static and a dynamic library of the same rootname in your path,
> it will always prefer the dynamic library, no matter what flags you
> specify. libtool does some kind of dance to get around this; CMake
> does not. If Apple is going to be that heavy handed with their
> linker, then as far as I'm concerned, they're aggressively anti-static
> and you're opening up cans 'o' worms going against them.
>
> I suppose static libs under my own control that link against dynamic
> runtimes are possible, but I'm not a Mac guy and do not deeply care
> about the issue. I adopted the expedient of suppressing static
> anything in Chicken's Mac build.
>
>
You can use this flag for ld if you want to change that:
-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.
At one, point I considered making this the default in CMake....
If you are building the libraries and there are only static ones, it
will use them.
So, to say they are deprecating static libraries is a bit of an over
statement.
They want you to use shared libraries, yes, but they are not getting rid
of static ones.
-Bill
More information about the CMake
mailing list