I have cross compiled c++ code for raspberry pi.
Below is process I followed:
1) Cloned the official toolchain from raspberry pi github. Set the environment variable of
2) Typed this command for generating binary for ARM architecture:
arm-linux-gnueabihf-c++ ./test.cpp -L. -lfoo -o test
3) Binary is successfully generated now. I tried to run the binary with below commands but had no luck with it.
LD_PRELOAD=/home/pi/Downloads/linux-sdk-demo-arm/libfoo.so ./test LD_LIBRARY_PATH=/home/pi/Downloads/linux-sdk-demo-arm ./test
I even set the environment variable in
.bashrc file but having no luck.
It gives the below errors respectively:
ERROR: ld.so: object './libfoo.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.<br/> ./test: error while loading shared libraries: libfoo.so: cannot open shared object file: No such file or directory
./test: error while loading shared libraries: libfoo.so: cannot open shared object file: No such file or directory
I'm sure the
libfoo.so file is there at the right path but it can not find it. Here's the directory structure:
-rw-rw-r-- 1 pi pi 15263 Jan 9 17:23 cp5200api.h -rw-rw-r-- 1 pi pi 1110 Mar 6 12:17 dtype.h -rwxrwxrwx 1 pi pi 152751 Mar 9 13:43 libfoo.so -rw-rw-r-- 1 pi pi 512 Mar 12 08:42 Makefile -rw-rw-r-- 1 pi pi 1285 Mar 8 20:13 notplugged -rw-rw-r-- 1 pi pi 1285 Mar 8 20:13 plugged -rwxr-xr-x 1 pi pi 13228 Mar 12 08:42 test -rw-rw-r-- 1 pi pi 2204 Mar 6 15:22 test.cpp