[CMake] CMake - overriding shared linker flags
K Lakshman
maruthilakshman-cmake at yahoo.com
Wed Jun 23 05:06:29 EDT 2010
Hi,
I'm trying to build a shared library (gcc on Linux CentOS) with -pie flag. If I
simply add the flag -pie to CMAKE_SHARED_LINKER_FLAGS "-Wl,-pie", the command
that gets invoked looks like this:
gcc -shared -Wl,-pie <rest of the command> -o libmylibrary.so
A shared library built like this is not runnable stand-alone (I get an error
/usr/lib/libc.so: bad ELF interpreter: No such file or directory). Where as if I
can get the shared library to be built using this command:
gcc -Wl,-shared -Wl,-pie <rest of the command> -o libmylibrary.so
then that shared library seems to run fine stand alone. (The only difference
betweent the two commands is that the -shared flags is passed to gcc in the
first version and directly to the linker in the second version thus bypassing
collect2).
How do I change the shared library build command to use -Wl,-shared instead of
-shared? Do I have to write a complete custom command or can I use some tricks
to simply change this part alone?
Thanks,
Lakshman.
More information about the CMake
mailing list