[英]RPi Cross Compiling: how to link dynamic libraries
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.我尝试从 x86_64 windows 机器交叉编译到运行 Raspberry OS lite 的 Raspberry Pi 4B,并且我已经设法使用我的工具链运行“hello world”。 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.现在,我想创建包含动态库的更复杂的程序,但我未能创建正确链接动态库的 makefile。 All libraries needed are available on the host as well as on the target device.主机和目标设备上都提供所需的所有库。 When i link the makefile on the host:当我在主机上链接 makefile 时:
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.编译过程中出现“No such file or directory”错误。
My question is: How can i link the dynamic libraries properly?我的问题是:如何正确链接动态库?
Thanks in advance!提前致谢!
lets try咱们试试吧
on host machine (windows):在主机(Windows)上:
add C:/SysGCC/raspberry64/aarch64-linux-gnu/sysroot/lib/aarch64-linux-gnu/ to your environment variable
My Computer>Properties>Advanced>Environment Variables>System Variables>Path>Edit>Variable Value
on target machine (linux)在目标机器上(linux)
env LD_LIBRARY_PATH=/opt/Vimba_5_1/VimbaC/DynamicLib/arm_64bit/ ./your_program
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如果有效 -> 您可以使用 ldconfig 将路径添加到库搜索路径https://blog.andrewbeacock.com/2007/10/how-to-add-shared-libraries-to-linuxs.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.