交叉编译为什么ld找不到共享库/如何进一步调试? [英] cross compiling why cant ld find shared library / how to debug further?

查看:727
本文介绍了交叉编译为什么ld找不到共享库/如何进一步调试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为我的arm路由器交叉编译和链接ubuntu上的聚合,但出现以下错误.过去,我认为我可以通过设置适当的环境变量来解决此问题,但这一次不起作用.谁能帮我弄清楚为什么这可能行不通:

Im trying to cross-compile and link aggregate on ubuntu for my arm-router and I get the following error. In the past I think I have been able to workaround this by setting the appropriate environment variable but this time is not working . Can anyone help me figure out why this might not work:

/home/ubuntu/Downloads/toolchain-arm_cortex-a9_gcc-4.9-linaro_musl-1.1.2_eabi/bin/../lib64/gcc/arm-openwrt-linux-muslgnueabi/4.9.1/../../../../arm-openwrt-linux-muslgnueabi/bin/ld:

cannot find -lpopt

但是libpopt.so存在于: lrwxrwxrwx 1 root root 34 Sep 10 12:46 /lib/x86_64-linux-gnu/libpopt.so -> /lib/x86_64-linux-gnu/libpopt.so.0

however libpopt.so exists in : lrwxrwxrwx 1 root root 34 Sep 10 12:46 /lib/x86_64-linux-gnu/libpopt.so -> /lib/x86_64-linux-gnu/libpopt.so.0

我无奈地将以下环境变量设置为无用.

I set the following environment variables , in order of desperation, to no avail.

LIBRARY_PATH=/lib/x86_64-linux-gnu/ LD_LIBRARY_PATH=/lib/x86_64-linux-gnu/ PATH=/lib/x86_64-linux-gnu/:/usr/include/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

LIBRARY_PATH=/lib/x86_64-linux-gnu/ LD_LIBRARY_PATH=/lib/x86_64-linux-gnu/ PATH=/lib/x86_64-linux-gnu/:/usr/include/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

考虑到可能是因为它可能是目标体系结构问题(例如,我需要针对交叉编译的目标而构建的libpopt.so)引起的,所以我将libpopt.so从路由器复制到了我的ubuntu并设置了再次的路径.再次无济于事.

Thinking that it might be caused because it might be a target architecture issue (ie maybe i need libpopt.so built for the target of the cross-compile) I copied the libpopt.so from the router to my ubuntu and set the paths again. Again to no avail.

我可能做错了什么?

谢谢

推荐答案

我必须在Makefile中使用-L指定lib的路径,如下所示: -L/lib/x86_64-linux-gnu/

I had to specify the path to the lib using -L in the Makefile as follows: -L/lib/x86_64-linux-gnu/

另外,我 did 必须使用libpopt.so的目标体系结构版本,该版本已复制到新目录中,并在-L/home/Downloads/lib/中使用.无论出于什么原因,都没有选择LIBRARY_PATH和LD_LIBRARY_PATH.

additionally I did have to use the target arhchitecture version of libpopt.so which i copied into a new dir and used that in the argument to -L/home/Downloads/lib/. For whatever reason LIBRARY_PATH and LD_LIBRARY_PATH were not being picked up.

这篇关于交叉编译为什么ld找不到共享库/如何进一步调试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆