[CMake] Cross-compilation linking against host libc

Alexander Neundorf a.neundorf-work at gmx.net
Tue Mar 31 16:11:41 EDT 2009


On Tuesday 31 March 2009, Adolfo Rodríguez wrote:
> 2009/3/30 Alexander Neundorf <a.neundorf-work at gmx.net>
>
...
> [1] In case you think it helps, these are my rpath settings:
>
> # Use, i.e. don't skip the full RPATH for the build tree
> set(CMAKE_SKIP_BUILD_RPATH  FALSE)
>
> # When building, don't use the install RPATH already
> # (but later on when installing)
> set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)


> # The RPATH to be used when installing
> set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
>
> # Add the automatically determined parts of the RPATH
> # which point to directories outside the build tree to the install RPATH
> set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

I'm not sure these two settings are good for cross compiling.
At least when I did cross compiling for really different targets, I usually 
installed the executables e.g. to ~/arm/inst/, but on the target platform 
this would be a different location, e.g. /opt or /usr/local (which could be 
NFS-mounted just from the local directory).
So while the files where installed, but on the host system the RPATH 
was "wrong", but once they were moved to their final location the RPATH was 
then the correct one.
This is also the case for you with the libc here. The executable doesn't have 
the RPATH set for the libc, so while it is on the build host system, ldd will 
show you the build host libc. Once you move it to the target system, ldd will 
automatically find the system libc there.

If this is not what you want, I would suggest to 
1) not use CMAKE_INSTALL_RPATH_USE_LINK_PATH when cross compiling
2) set CMAKE_INSTALL_RPATH explicitely to the directories you want on the 
target platform

Alex


More information about the CMake mailing list