Cross-compilation Environment and Development Board-/bin/sh:./Hello: not found
The target board is S3C2440. As for the establishment of the Cross-compilation environment, there are many tutorials on the Internet.
After the cross-compilation environment is set up, the first thing is the legendary "Hello, world !".
1. Host Compilation
My system is ubuntu10.04. After the cross-compilation environment is set up, the terminal enters arm-Linux-gcc-V to display the version information normally, however, after entering sudo arm-Linux-gcc-V, the command cannot be found.
I have tried many methods. For example, after Sudo-S switches to root, edit $ path and add the compiler path. then exit to the normal user. sudo arm-Linux-gcc-v. if any Daniel knows the reason, leave a message to tell me, thank you :)
Due to compilation. c file, to generate a new file, so the super permission is required. you cannot use sudo arm-Linux-GCC, so you can use Sudo-S to the root user before using ARM-liunux-GCC for compilation.
II. Implementation of the target board
I use ftp to transfer files between the host and the target board. Pay attention to changing permissions after transfer.
Note the following points:
1. Determine the default file storage path after ftp. You only need to confirm it on the terminal of the target machine. (The command cannot be found if it is not confirmed)
2. You need to change the permission of the transferred file to run the file. You can use:
Chmod 777 hello
Chmod + x hello
3. Execute./Hello
At this time, an error is reported:-/Bin/sh:./Hello: not found
Iii. troubleshooting
After an absolute path is used and a try is made, it is not a problem with the file,This file cannot be executed.
After Google detects that the problem is resolvedDynamic Link Library.
Therefore, the host uses arm-Linux-gcc-static-O for static compilation. then upload the new file to the target board. it can be found that static files are much larger than dynamic files.
Then execute./Hello again. We can see that there has been a long-overdue hello, world!
The problem has not been solved yet. We can think about how to solve it completely, instead of using static compilation every time.
Since it is a problem caused by the dynamic library, it should be related to the compiler version. both versions 3.4.1 and 4.3.3 are installed when the compiling environment is installed. in the user manual, 3.4.1 is used to compile U-boot, and 4.3.3 is used to compile Linux kernel and qtipia. Both versions can be used to compile applications.Program.
Since our kernel is compiled using 4.3.3, And we just compiled Hello using 3.4.1, will this be the reason?
So let's try to change the original path 3.4.1/bin in $ path to 4.4.3/bin. There are many ways to modify it online. (directly export Path = "desired path ")
Compile and download again.
Execute on the target board. "Hello, world!" is displayed successfully !".
We can see that the support for dynamic libraries in the system is related to the compiler.
Do you have any questions orArticleIf you have any mistakes, let's discuss them: D.