RPi交叉编译:如何链接动态库
我尝试从 x86_64 Windows 机器交叉编译到运行 Raspberry OS lite 的 Raspberry Pi 4B,并且我已经成功使用我的工具链运行“hello world”。现在,我想创建包含动态库的更复杂的程序,但我无法创建正确链接动态库的 makefile。 所需的所有库都可以在主机和目标设备上使用。 当我链接主机上的 makefile 时:
LIBRARIES := C:/SysGCC/raspberry64/aarch64-linux-gnu/sysroot/lib/aarch64-linux-gnu/libdl.so.2
程序编译正确,但在目标上执行会出现错误:“加载共享库时出错:没有这样的文件或目录”。这是绝对有道理的。
但是,当我链接目标的库时:
LIBRARIES := /opt/Vimba_5_1/VimbaC/DynamicLib/arm_64bit/libVimbaC.so /usr/lib/aarch64-linux-gnulibdl.so.2
编译过程中出现错误“没有这样的文件或目录”。
我的问题是:如何正确链接动态库?
提前致谢!
I try to cross compile from an x86_64 windows machine to a Raspberry Pi 4B running Raspberry OS lite and i already managed to run a "hello world" with my toolchain. Now, i want to create more complex programs which include dynamic libraries, and i fail in creating a makefile which links the dynamic libraries correctly.
All libraries needed are available on the host as well as on the target device.
When i link the makefile on the host:
LIBRARIES := C:/SysGCC/raspberry64/aarch64-linux-gnu/sysroot/lib/aarch64-linux-gnu/libdl.so.2
The program compiles properly, but the execution on the target rises the error: "error while loading shared libraries: no such file or directory". Which makes abosulte sense.
But, when i link the libraries of the target:
LIBRARIES := /opt/Vimba_5_1/VimbaC/DynamicLib/arm_64bit/libVimbaC.so /usr/lib/aarch64-linux-gnulibdl.so.2
The error "No such file or directory" arises within the compilation process.
My question is: How can i link the dynamic libraries properly?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
让我们
在主机(windows)上尝试一下:
在目标机(linux)上
尝试一下,如果它工作 ->您可以使用 ldconfig 将路径添加到库搜索路径
https://blog.andrewbeacock。 com/2007/10/how-to-add-shared-libraries-to-linuxs.html
lets try
on host machine (windows) :
on target machine (linux)
if it work -> you can add the path to library searching path with ldconfig
https://blog.andrewbeacock.com/2007/10/how-to-add-shared-libraries-to-linuxs.html