I'm going to Cross Compile my simple 'Hello World' Program with this toolchain:
arm-hisiv100-linux
and then run on a target which does not have any built-in library.
I have tested my toolchain with and without -static option
arm-hisiv100-linux-gcc HelloWorld.c -o HelloWorld-static -static
arm-hisiv100-linux-gcc HelloWorld.c -o HelloWorld
file HelloWorld-static
HelloWorld-static: ELF 32-bit LSB executable, ARM, version 1 (SYSV), statically linked, not stripped
file HelloWorld
HelloWorld: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), not stripped
My dynamically Program only requires libc.so.0 (which is only a link to libuClibc-0.9.32.1.so) to run,
objdump -x HelloWorld |grep NEEDED
NEEDED libc.so.0
and I found it in the toolchain's library
file /opt/hisi-linux-nptl/arm-hisiv100-linux/target/lib/libuClibc-0.9.32.1.so
/opt/hisi-linux-nptl/arm-hisiv100-linux/target/lib/libuClibc-0.9.32.1.so: ELF 32-bit LSB shared object, ARM, version 1 (SYSV), dynamically linked (uses shared libs), stripped
but the libuClibc-0.9.32.1.so also have its dynamic dependency
objdump -x /opt/hisi-linux-nptl/arm-hisiv100-linux/target/lib/libuClibc-0.9.32.1.so |grep NEEDED
NEEDED ld-uClibc.so.0
file /opt/hisi-linux-nptl/arm-hisiv100-linux/target/lib/ld-uClibc-0.9.32.1.so
/opt/hisi-linux-nptl/arm-hisiv100-linux/target/lib/ld-uClibc-0.9.32.1.so: ELF 32-bit LSB shared object, ARM, version 1 (SYSV), dynamically linked, stripped
So I copied NEEDED libraries 'libuClibc-0.9.32.1.so' and 'ld-uClibc-0.9.32.1.so' to the target (actually I use NFS), and then modify the LD_LIBRARY_PATH variable.
myTarget # ls
HelloWorld HelloWorld-static HelloWorld.c libc.so.0 ld-uClibc.so.0
myTarget # chmod +x HelloWorld HelloWorld-static
myTarget # export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/
myTarget # export
export HOME='/'
export LD_LIBRARY_PATH='/usr/local/lib:/usr/lib:/mnt/mtd/share/HelloWorldProgram/'
export LOGNAME='root'
export OLDPWD='/mnt/mtd/share'
export PATH='/usr/bin:/usr/sbin:/bin:/sbin'
export PWD='/mnt/mtd/share/HelloWorldProgram'
export SHELL='/bin/sh'
export TERM='vt102'
export USER='root'
I successfully run HelloWorld-static but not the HelloWorld
./HelloWorld-static
Hello EveryBody, this is my simple HelloWorld
./HelloWorld
-sh: ./HelloWorld: not found
I have no idea what i've missed
Any idea or help would be appreciated.
Best Regards
Loi Dang