title: RPi Cross Compiling: how to link dynamic libraries
body: <p>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 &quot;hello world&quot; 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:</p>
  <p><code>LIBRARIES := C:/SysGCC/raspberry64/aarch64-linux-gnu/sysroot/lib/aarch64-linux-gnu/libdl.so.2</code></p>
  <p>The program compiles properly, but the execution on the target rises the error: &quot;error while loading shared libraries: no such file or directory&quot;. Which makes abosulte sense.</p>
  <p>But, when i link the libraries of the target:</p>
  <p><code>LIBRARIES := /opt/Vimba_5_1/VimbaC/DynamicLib/arm_64bit/libVimbaC.so /usr/lib/aarch64-linux-gnulibdl.so.2</code></p>
  <p>The error &quot;No such file or directory&quot; arises within the compilation process.</p>
  <p>My question is: How can i link the dynamic libraries properly?</p>
  <p>Thanks in advance!</p>