[CMake] Cross-compiling on OS X/x86 for Linux/ARM, linking a library
Alexander Neundorf
a.neundorf-work at gmx.net
Mon Oct 19 15:18:55 EDT 2009
On Monday 19 October 2009, Vladimir Lebedev-Schmidthof wrote:
> Hello everyone,
>
> Two compiling platforms - Linux and OS X.
> Same project, same cmake (2.6.4), same target (Linux/ARM).
>
> Sources compiles well (GNU C/C++) but linking is different.
>
> Everything is fine on Linux.
>
> comparing make VERBOSE=1 outputs:
>
> OS X: [path-to]/gcc -march=armv5te -mtune=xscale -msoft-float -fpic -
> mthumb-interwork -ffunction-sections -funwind-tables -fstack-protector
> -fno-short-enums -dynamiclib -nostdlib -Wl,-shared,-Bsymbolic -Wl,-
> rpath-link=[path-to]/usr/lib -Wl,--whole-archive -Wl,--no-undefined -
> Wl,-rpath-link=[path-to]/usr/lib -o libmylib.so -install_name /Users/
> dair/Project/native/libmylib.so [source-files]
>
> Linux: [path-to]/gcc -fPIC -march=armv5te -mtune=xscale -msoft-float -
> fpic -mthumb-interwork -ffunction-sections -funwind-tables -fstack-
> protector -fno-short-enums -nostdlib -Wl,-shared,-Bsymbolic -Wl,-rpath-
> link=[path-to]/usr/lib -Wl,--whole-archive -Wl,--no-undefined -Wl,-
> rpath-link=[path-to]/usr/lib -shared -Wl,-soname,libmylib.so -o
> libmylib.so [source-files]
>
> The problem is "-install_name" option. Cmake generates that in OS X
> but GCC cross-compiler does not accept that. I can successfully link
> the library (manually) by removing this option.
>
> I set CMAKE_SYSTEM to Linux, even added "SET(APPLE 0)" but
> install_name option is still generating.
You should set "CMAKE_SYSTEM_NAME", not "CMAKE_SYSTEM" to "Linux". If you
really set CMAKE_SYSTEM instead of CMAKE_SYSTEM_NAME, this will fix your
problem (after a quick look it seems install_name is really only set in the
Modules/Platform/Darwin*.cmake files, which should not get loaded if
CMAKE_SYSTEM_NAME is set to Linux).
Alex
More information about the CMake
mailing list