Skipping incompatible /lib/libc.so.6 when searching for /lib/libc.so.6

By | May 18, 2016

When cross-building a program (but this could also happen when building natively), it’s normal that we don’t have the environment variables and building flags set with the right paths that indicate where the toolchain and the sysroot are.

The wrong paths can lead to many types of building errors at different stages. This one happened to me recently:

This linking error says that it is skipping an incompatible library that is searching in my host’s filesystem even though I explicitly indicated in the Makefile the paths to use in the environment variable LDFLAGS with the -L:

The $SYSROOT environment variable was set correctly

To indicate the linker to use the right path you have to add the -Xlinker -rpath-link=/your/sysroot/path directives.

For adding the /lib and /usr/lib path that are in my sysroot, the previous setting of LDFLAGS becomes:

Now the linker does not complain anymore.

Leave a Reply

Your email address will not be published. Required fields are marked *