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. _______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
