last day (18 days later) » 

8:37 AM
0
Q: How to cross compile c++ code to ARMv7L architecture?

AniketBelow is process i followed 1 ) Cloned the official toolchain from raspberry pi github ( URL : https://github.com/raspberrypi/tools) 2 ) Set the environment variable of arm-linux-gnueabihf-c++ ( in .bashrc file ) 3 ) Typed this command for generating binary for ARM architecture arm-linux-gnue...

 
Has the library been compiled for ARMv7? I doubt it.
 
No, When i type file libCP5200.so it shows ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, BuildID[sha1]=af8a7e3f60ee3444c75ab8b1e6816776f8fed8e9, not stripped
 
This simply cannot work. ARM CPUs cannot run x86 binaries. You have to recompile the library first.
 
Is there any way i can compile current .so file from i386 to arm architecture ?
 
No. You need the sources of that library.
 
8:37 AM
Okay, thank you very much for the information :) . I hope there is some way of doing it
@Janka i got the ARM version .so file. Now binary executable file generated. But when running executable file on raspberry pi it shows cannot open shared object file . I already set LD_LIBRARY_PATH to the location of binary path ( /home/pi/Rpi/ )
 
 
2 hours later…
10:58 AM
What does ldd ./test say?
 
11:10 AM
libCP5200.so -> Not found
When i typed readelf -A libCP5200.so
output is
 
11:46 AM
ile Attributes
Tag_CPU_name: "ARM10TDMI"
Tag_CPU_arch: v5T
 
12:41 PM
@Janka Will ARMv10 compiled .so file will run on ARMv7 ?
 
I'd expect a NO.
But the problem you have is about the path. By specifying -L. you had put the current directory into the executable file. That's not helpful.
 
@Janka Yes i have changed the path afterwards
 
try with LD_PRELOAD=./libCP5200.so ./test
 
ok let me try this
`ERROR: ld.so: object './libCP5200.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
./test: error while loading shared libraries: libCP5200.so: cannot open shared object file: No such file or directory `
@Janka i'm getting this error
This is the command i am using arm-linux-gnueabihf-g++ ./test.cpp -L. -lCP5200 -o test
and then run using LD_LIBRARY_PATH=. ./test
 
12:58 PM
ls -l directory listings are much more helpful.
Your problem is about not being in the directory the library file is in when you are running the executable.
You could also specify an absolute path in LD_PRELOAD= This is recommend anyway.
 
-rw-rw-r-- 1 pi pi 15263 Jan 9 17:23 cp5200api.h
-rw-rw-r-- 1 pi pi 15456 Mar 6 12:15 cp5200api(old).h
-rw-rw-r-- 1 pi pi 1110 Mar 6 12:17 dtype.h
-rw-rw-r-- 1 pi pi 138451 Jan 10 14:21 libCP5200(old).so
-rw-rw-r-- 1 pi pi 152751 Mar 9 2018 libCP5200.so
-rw-rw-r-- 1 pi pi 484 Mar 9 10:48 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 13244 Mar 9 10:48 test
-rw-rw-r-- 1 pi pi 2204 Mar 6 15:22 test.cpp
 
Ok, now LD_PRELOAD=./libCP5200.so ./test should work. You can also test with LD_PRELOAD=./libCP5200.so ldd ./test
Have to leave for two hours. Sorry.
 
its not working :(
okay thank you for the support
will wait for solution from your side :)
 
 
2 hours later…
3:06 PM
What's the output of LD_PRELOAD=./libCP5200.so ldd ./test?
 

  last day (18 days later) »