linux无法打开共享对象文件或目录,linux - libmodbus.so.5:无法打开共享对象文件:没有这样的文件或目录 - 堆栈内存溢出...

主持人:Linux BBB-VirtualBox 3.19.0-25-generic#26〜14.04.1-Ubuntu SMP Fri Jul 24 21:16:20 UTC 2015 x86_64 x86_64 x86_64 GNU / Linux

目标:Linux beaglebone 3.8.13-bone70#1 SMP Fri Jan 23 23:15:42 UTC 2015 armv7l GNU / Linux

通过运行以下命令,我在主机上编译了libmodbus:

./autogen.sh

./configure --host=arm-linux-gnueabi --prefix=/home/BBB/build

sudo make

sudo make install

和lib和include将在路径/home/BBB/build ,复制到目标系统路径/usr/local并运行sudo ldconfig 。

然后我建立应用程序:

arm-linux-gnueabi-gcc main.c $(pkg-config --libs --cflags ~/BBB/build/lib/pkgconfig/libmodbus.pc)

在目标上运行并返回错误:

root@beaglebone:~# ./a.out

./a.out: error while loading shared libraries: libmodbus.so.5: cannot open shared object file: No such file or directory

但我可以在/usr/local/lib找到libmodbus.so.5 :

root@beaglebone:~# file a.out

a.out: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=0x4bc4bfa11806ebaffdd359ccf3a3144a4fda0a75, not stripped

root@beaglebone:~# find / -name "libmodbus*"

/usr/local/lib/libmodbus.so

/usr/local/lib/pkgconfig/libmodbus.pc

/usr/local/lib/libmodbus.la

/usr/local/lib/libmodbus.so.5.1.0

/usr/local/lib/libmodbus.so.5

/usr/local/include/libmodbus

......

我将库路径添加到ld.so.conf和LD_LIBRARY_PATH但仍然返回相同的错误。

root@beaglebone:~# cat /etc/ld.so.conf

include /etc/ld.so.conf.d/*.conf

/usr/local/lib

root@beaglebone:~# echo $LD_LIBRARY_PATH

/usr/local/lib:

root@beaglebone:~# ldconfig -p | grep libmodbus

libmodbus.so.5 (libc6) => /usr/local/lib/libmodbus.so.5

libmodbus.so (libc6) => /usr/local/lib/libmodbus.so

编译应用程序时尝试添加-Wl,-rpath=/usr/local/lib ,但仍然返回错误。

当我配置libmodbus并静态编译应用程序时,该应用程序运行得很好。

我该怎么办?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值