[CMake] Specifying linker flags for shared library build

Petr Kmoch petr.kmoch at gmail.com
Wed May 30 03:56:27 EDT 2012


Hi Jonathan.

On Tue, May 29, 2012 at 8:41 PM, Jonathan Romero <jonnyro at jonnyro.com> wrote:
> Hello,
>
> I am running a build using cmake using the Meego 1.2 toolchain (long
> story).  This particular toolchain requires the --sysroot option to be used
> to find any libraries it requires.
>
>     set (CMAKE_CXX_FLAGS "-fpermissive")
>     set (CMAKE_CXX_LINK_FLAGS "--sysroot=${INTEL_GRAPHICS_SDK_BASE}/sdk")
>     set (CMAKE_CXX_FLAGS_DEBUG "-g")

The cmake variable for linker flags is not based on language, but on
SHARED/EXE/MODULE, and it's LINKER, not LINK. So the variable you
should set is:

set (CMAKE_SHARED_LINKER_FLAGS "--sysroot=${INTEL_GRAPHICS_SDK_BASE}/sdk")

I hope it helps.

Petr

>
> These options allow the cmake initial compiler checks to pass, but when
> producing a shared library during the build it looks like ld is being called
> without any of the options specified.
>
> Is there a different cmake variable that needs to be set to specify the
> sysroot for shared libraries?
>
> The error I am getting is
>
>
>
> /usr/lib/madde/linux-i686/toolchains/meego-1.2-sdk-ia32-toolchain-1.0-linux_i686/i586-meego-linux-gnu/bin/../lib/gcc/i586-meego-linux-gnu/4.5.1/../../../../i586-meego-linux-gnu/bin/ld:
> crti.o: No such file: No such file or directory
>     collect2: ld returned 1 exit status
>
>
> Interestingly enough there are some linker options being passed.
> Specifically the output name. Is this perhaps overwriting my attempts to
> specify linker options?
>
>
> These are the flags that are generated:
>
> /usr/lib/madde/linux-i686/toolchains/meego-1.2-sdk-ia32-toolchain-1.0-linux_i686/i586-meego-linux-gnu/bin/i586-meego-linux-gnu-g++
> -fPIC -g   -shared -Wl,-soname,mylib_ES11_debug.so -o
>
> Cheers,
>
> Jonathan
>
>
>
> --
> Jonathan S. Romero
>
> --
>
> 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


More information about the CMake mailing list