I recently want to develop embedded Linux, but most of the documents on hand introduce that the cross-compilation environment is based on RedHat9. Although this version is classic, it is too old after all, I installed Ubuntu9.04 on my machine, so I did a little research, in Ubuntu9.04 install the cross compiling environment arm-linux-gcc replace all yournames with your own username in the/home directory first quasi-this work: the required installation package: crosstool-0.43
I recently want to develop embedded Linux, but most of the documents on hand introduce the cross-compilation environment based on RedHat 9. Although this version is classic, it is really too old after all, I installed Ubuntu 9.04 on my machine, so I did a little research, install the cross-compiling environment in Ubuntu 9.04. Replace yourname in arm-linux-gcc with your username in the/home directory.
The first is quasi-work:
Required installation package:
Crosstool-0.43.tar.gz can be obtained at http://kegel.com/crosstool/crosstool-0.43.tar.gz
Create a folder
Mkdir/home/yourname/downloads can also be used by mkdir ~ /Downloads
Copy crosstool-0.43.tar.gz to the downloads directory (by default, the download is actually performed on the desktop)
In addition, there are some installation packages:
Binutils-2.16.1.tar.bz2
Glibc-2.3.2.tar.bz2
Glibc-linuxthreads-2.3.2.tar.bz2
Gcc-3.3.6.tar.bz2
Linux-2.6.15.4.tar.bz2
Gcc-4.1.0.tar.bz2
Linux-libc-headers-2.6.12.0.tar.bz2
Gdb-6.5.tar.bz2
These will be automatically downloaded during the installation process, or you can download them in advance and put them under/home/yourname/downloads. However, I suggest you download them in advance, because a file in glibc needs to be modified later.
The following are some problems that may be encountered during installation. Please come out in advance, saving you the trouble of compiling for half a day and re-compiling if you find the error. If you want to see these problems, you can directly jump to the following installation process.
1. The following two packages are missing during installation.
Bison
Flex
If you have not installed the package before, download and install it. (If you have forgotten the package name, you can enter bison to check the package. If you have not installed the package, you will be prompted to download the packages for installation. flex is similar)
Sudo apt-get install bison
Sudo apt-get install flex
In addition, an mm4 is needed on the Internet, but I didn't prompt when installing it. It seems that flex is automatically installed when dependency is resolved.
2. another inexplicable error is that the gcc version is too old or not installed, but when you use sudo apt-get install gcc, you will find that gcc is already the latest version, in fact, this error is because the gcc version is too new. The solution is as follows:
Sudo apt-get install gcc-3.4
Cd/usr/bin
Sudo rm gcc
Ln-s gcc-3.4 gcc
3. the following error occurs during installation:
/Home/xxs/crosstool-0.43/build/arm-arm9tdmi-linux-gnu/gcc-4.1.1-glibc-2.3.2/build-glibc/csu/version-info.h: 1: missing terminating "character
The system found an error in the version-info.h file when compiling version. o.
The solution is to modify a file.
Decompress glibc-2.3.2.tar.bz2
Locate Makefile under the glibc-2.3.2/csu directory and modify as follows
There are two echo records at the end of the file.
Echo
"\" Compiled on a $ OS $ version system "\
"On
'Date + % Y-% m-% D'. \ n \"";;\
Changed:
Echo
"\" Compiled on a $ OS $ version system "\
"On
'Date + % Y-% m-% D'. \\\\ n \"";;\
Echo
"\" Available extensions: \ n \"";
Changed:
Echo
"\" Available extensions: \\\\ n \""\
Save and re-compress glibc-2.3.2.tar.bz2 to overwrite the original glibc-2.3.2.tar.bz2 in the downloadsdirectory.
To solve some of the above problems, you can start the installation.
1. Create an installation directory
Sudo mkdir/opt/crosstool
This is because the installation file is installed in this directory by default.
2. add permissions for yourself
Sudo chown yourname/opt/crosstool
3.decompress crosstools-0.43.tar.gz (the installation package should be in the/home/yourname/downloads/directory, if not, change it by yourself)
Tar-zvxf crosstools-0.43.tar.gz
Go to the cross directory
Cd cross-0.43
You can take a look at the files in the ls, which contain some script files. For specific functions, visit http://kegel.com/crosstoolto refer to FAQs.
4. Run./demo-arm.sh for Installation
In this step, some people on the Internet say that they need to modify some settings in the script file. I have installed them without modification. I don't know why.
5. The rest is waiting for compilation and installation. It's a long time ~~
Modify Environment Variables
After the installation is complete, the default installation directory is the/opt/crosstools/
1. Add Environment Variables
Gedit ~ /. Bashrc
Add the following
If [-d/opt/crosstool/gcc-4.1.0-glibc-2.3.2/arm-unknow-linux-gnu]; then
Paths =/opt/crosstool/gcc-4.1.0-glibc-2.3.2/arm-unknow-linux-gnu/bin: $ PATH
Fi
Add the bin directory of the installed tool to the PATH variable.
Save
2. source ~ /. Bashrc
3. Restart the terminal.
Then you can test it.
Arm-unknow-linux-gnu-gcc
Normally
Arm-unknow-linux-gnu-gcc: no input files
Indicates that the program can be used.
The rest is to continue exploring ~
The revolution is not yet successful, and comrades still need to work hard
**************************************** *************
A patch error occurs during installation. What is the error. sh file, which is clearly in the folder but cannot be found, and then re-installed a patch, apt-get install patch, which will be ready for re-installation.
It took a long time to finally install the program, but it didn't respond when setting the environment variable. Find the Directory and run./arm-unknow-linux-gnu-gcc to display no input files.
However, environment variables are not properly configured and can only be executed in the file directory.