[CMake] Cross-compiling on OS X/x86 for Linux/ARM, linking a library
Vladimir Lebedev-Schmidthof
vlebedev at envionsoftware.com
Mon Oct 19 14:07:52 EDT 2009
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.
Also, on OS X Cmake generates CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS as "-
dynamiclib -headerpad_max_install_names" which I don't need (-
headerpad_max_install_names is not recognized by my compiler) but I
can obviously set that property to what I need.
Please advise.
--
Thanks in advance,
Vladimir
More information about the CMake
mailing list