[CMake] long library names
Bill Hoffman
bill.hoffman at kitware.com
Wed Aug 15 22:24:29 EDT 2007
James Bigler wrote:
> Alexander Neundorf wrote:
>> On Wednesday 15 August 2007 14:42, James Bigler wrote:
>>> When I run FIND_LIBRARY(MYLIB mylib), the value of MYLIB is the full
>>> path to mylib (i.e. /home/bigler/lib/libmylib.a). When I go to link
>>> the executable it breaks it up into -L/home/bigler/lib -lmylib.
>>>
>>> Is there a way to get CMake to put /home/bigler/lib/libmylib.a on the
>>> link line instead of breaking it up into path/short name?
>>
>> No. Why do you need this, it shouldn't be necessary ?
>
> It is necessary on the Mac. GCC on Macs will search *all* the library
> paths for a shared version of the library, then search again for a
> static version. Since a shared version exists in the default path,
> /usr/lib, no amount of -L/mypath will get it to pick the static
> version unless I specify the static library explicitly.
>
> There was another thread about this shared library issue a couple of
> days ago.
Add this flag to your CMAKE_EXE_LINKER_FLAGS:
-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.
That will fix the problem on the Mac, I think I am going to make this a
default flag on the Mac since the -l stuff does not work correctly
without it.
-Bill
More information about the CMake
mailing list