GCC linker search path when cross-compiling

I have various tool chain directories on my linux machine for compiling under specific compiler versions. I have a problem where the linker (in the tool chain dir) is selecting a library file from the native machine (/lib, for example) rather than the one in the tool chain (/toolchain/lib/...). This results in various linker errors such as:

The link is failing because it is linking /lib/x86_64-linux-gnu/libxmlrpc_client.so.3 (native file on my Ubuntu) instead of /opt/foo/cross_x86_64_v9b/lib64/libxmlrpc_client.so.3 (tool chain version).

Here's the search paths as far as I can figure:

If I remove the libxml... files from /lib/x86_64-linux-gnu then the link succeeds, so somehow that path is being searched ahead of the SEARCH_DIR above. All the system libraries being linked should be under /opt/foo/cross_x86_64_v9b.

Neither LD_PATH nor LD_LIBRARY_PATH are defined in my environment. Why is the linker searching /lib before /opt/foo/cross_x86_64_v9b/lib64/? How can I correct this?

添加评论
点赞收藏
点踩分享查看原文
评论
?
参与讨论