简体   繁体   中英

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. 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!

lets try

on host machine (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)

   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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM