[CMake] linker flags for FreeBSD
Brad King
brad.king at kitware.com
Wed Jun 8 11:52:29 EDT 2005
Alexander Neundorf wrote:
> when creating a shared library on FreeBSD with the flags
> "-Wl,--fatal-warnings -Wl,--no-undefined"
> I get undefined reference to everything from libc. Adding "-lc" helps. So
> shouldn't "-lc" be added automatically on FreeBSD for linking shared libs
> and modules ?
I've now investigated this issue. It appears to happen on other UNIX
platforms such as Sun too. This is basically the same problem as adding
-lm on UNIX platforms if one uses any math symbols. Since it is
perfectly valid to create a shared library or module that does not
reference any standard C library symbols, we do not want to force -lc on
the users. If a particular platform does force this option (such as
Linux) then that is a problem for the users of that platform if they
don't want it. Therefore the resolution of this problem is just to
require the CMakeLists.txt code to add -lc if it is building a library
that references C library symbols:
IF(UNIX)
SET(MY_LIBC_FLAGS "-lc")
ELSE(UNIX)
SET(MY_LIBC_FLAGS "")
ENDIF(UNIX)
-Brad
More information about the CMake
mailing list