开发者

cross compile issue with simple hello program

开发者 https://www.devze.com 2023-04-08 06:42 出处:网络
Background : Trying to setup a cross compiler environment for arm target (TQ2440/Mini2440) On HOST running Red Hat:

Background : Trying to setup a cross compiler environment for arm target (TQ2440/Mini2440)

On HOST running Red Hat:

  1. Wrote a simple hello program
  2. gcc -o hello hello.c
  3. compiles successfully
  4. ./hello
  5. displays the hello world message
  6. rm hello
  7. arm-linux-gcc -o hello hello.c
  8. file hello
  9. It says 32bit compiled for ARM compatible for Linux 2.0.0

Transfer the "hello" binary file to TARGET

  1. chmod a+x hello
  2. ./hello
  3. The problem:

    /bin/sh: ./hello: not found
    

Can anyone point out my mistake or what am I missing here?


I executed ldd on host: ldd hello and I got:

/usr/local/arm/3.3.2/bin/ldd: line 1:  
/usr/local/arm/3.3.2/lib/ld-linux.so.2: cannot execute binary file 
/usr/local/arm/3.3.2/bin/ldd: line 1: 
/usr/local/arm/3.3.2/lib/ld-linux.so.2: cannot execute binary file 
ldd: /usr/local/arm/3.3.2/lib/ld开发者_运维知识库-linux.so.2 exited with unknown exit code (126)


Solved.

I was transfering the file through ftp. You need to enter bin to switch to binary transfer mode. Works fine now.


Try running ldd hello and see if it complains about any missing dynamic libraries.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号