[CMake] Cross-compilation linking against host libc

Adolfo Rodríguez dofo79 at gmail.com
Tue Mar 31 04:49:40 EDT 2009


2009/3/30 Alexander Neundorf <a.neundorf-work at gmx.net>

> On Monday 30 March 2009, Adolfo Rodríguez wrote:
> > Hi,
> >
> > I have set up a toolchain file [1] to enable cross-compiling a project.
> In
> > my current setup, both the host and target environments are
> > binary-compatible (both are x86 and are using gcc's with compatible
> ABIs).
> > When I generate a cross-compiled executable and run ldd, the paths to
> > libraries such as libc, libc++, and m show up rooted at /lib. I was
> > expecting something more in the line of ${CMAKE_FIND_ROOT_PATH}/lib.
> > Conversely, the external dependencies I explicitly added using
> > find_libraries appear rooted at ${CMAKE_FIND_ROOT_PATH}, which is what I
> > expected.
> >
> > Is this behavior correct, or did I misunderstood something along the way?
> >
> > In case it helps, my toolchain file looks something like this:
>
> Looks ok.
> Did you check the executable in the build tree or installed ? This matters
> because this changes the RPATH. If you build without RPATH, you will get
> what
> ld finds, which is probably libc in /lib.
>

I checked both my build and my installation trees. In both cases ldd says
that libc is taken from /lib, instead of ${CMAKE_FIND_ROOT_PATH}/lib
I use rpath settings in my project [1], and I can verify the -rpath flag
value when I do 'make VERBOSE=1'. Its value points to the folders where my
external deps are located, but not to the location of libc. Does rpath only
affect the libraries I explicitly link against?

[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)


Thanks,


-- 
Adolfo Rodríguez Tsouroukdissian

Robotics engineer
PAL ROBOTICS S.L
http://www.pal-robotics.com
Tel. +34.93.414.53.47
Fax.+34.93.209.11.09
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090331/23c3a44a/attachment.htm>


More information about the CMake mailing list