Before we start learning Linux system development we need to install some code compiler environment.
arm-linux-gcc compiler.
The first step, we need to first install the basic development environment, the command is as follows:
sudo apt-get install build-essential
After installation is complete, but also were installed bison, flex, they are grammatical, lexical analyzer.
Command is as follows:
sudo apt-get install bison flex
After installation need to install some C library functions man pages, so you can view the usage of the function by man read command.
Command is as follows:
sudo apt-get install manpages-dev
Here it is already installed before.
Here we have basically completed the installation environment, we took in a cross-compiler installed.
The second step, install GCC cross compiler tool
First copy arm-linux-gcc-3.4.5-glibc-2.3.6.tar.bz2 samba file to a shared folder.
Then copy the file to gcc_tools folder, and then unzip. (Personal habit)
Then enter the command to extract: tar xjf arm-linux-gcc-3.4.5-glibc-2.3.6.tar.bz2, as shown:
This time is extracted.
Then set the environment variable: $ export PATH = $ PATH: /home/shao/shao/gcc_tools/gcc_3.4.5-glibc-2.3.6 (Here we note that "=" no spaces at both ends).
You can also set an absolute path environment variable, save after each time knocking environment variables:
PATH="/usr/local/sbin:/usrlocal/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games: /home/shao/shao/gcc_tools/gcc-3.4.5-glibc-2.3.6/bin"
设定完成后我们还需要安装一下 ncurses,这是一个体能功能键定义(快捷键)、屏幕绘制以及基于文本终端的图形交互动态库。
如果没有这个库,在执行“make menuconfig”时会出错。
命令如下:
到这里我们的交叉编译器已经安装完毕。
我们可以测试一下,在windows_share里面放入test.c文件,功能是用来打印一句hello world!.
操作如下图:
gcc -o hello test.c
在这句话中gcc是指定用来编译的编译器是哪个。
-o是编过程中的编译选项。
hello是编译后生成的可执行文件
test.c是我们被编译的源文件。
编译完成后就会产生一个可执行文件 hello, 注意:这里这个hello没有后缀名。
然后用 ./hello就可以看到执行效果了。如下图:
到这里我们安装完成!
arm-linux-gcc编译器也是这个一起安装完成了。接下来我们查看一下:
输入指令:arm-linux-gcc -v