[CMake] Linking with -l and -L flags

William A. Hoffman billlist at nycap.rr.com
Thu Jan 12 13:15:35 EST 2006


At 12:46 PM 1/12/2006, Moreland, Kenneth wrote:
>I have noticed that for Unix makefile generators, when you specify the
>path of a library with LINK_LIBRARIES or TARGET_LINK_LIBRARIES, the path
>is converted to -L and -l flags in the link line?  Is there a good
>reason to do this versus just adding the full path of the library to the
>link line?
>
>I am arguing that this is the wrong behavior.  The problem is that
>sometimes I'll specify a specific library, but the linker will actually
>load in a different one with the same name but is nonetheless not
>compatible with my build.  Current example: I am trying to compile
>ParaView on my Mac with static libraries (to make distribution easier).
>It compiles its own static Tck/Tk libraries, but the linker grabs the
>system Tck/Tk libraries because they are dynamic.  The resulting
>executable crashes because the system Tcl/Tk libraries use a different
>graphics API.
>
>Right now I can find no choice but to modify the makefiles that are
>built.  Is there a better solution?

The problem is that on some systems full paths to libraries cause the
compiler to pull in ALL symbols and not just the ones used, sort of like
*.o.

There is a part of cmake that orders the -L paths and should complain if 
it can not come up with the correct order for full path specified libraries.
Are you getting a warning, or is the tcl being specified without a full path?

-Bill



More information about the CMake mailing list