Experiment 4 Linux System C language development environment for learning
project | content |
---|---|
This work belongs courses | Course Link |
Where this requirement in the job | Link address operational requirements |
Student ID - Name | 15012214- Wanghao Dong |
Job learning objectives | 1. Linux System C language development environment to build 2. Learning C language development environment of Linux systems process |
Install the C language development environment
1. Check the version information of gcc
2. Check the version information make
Simple C language exercises
1. First, we help documentation via the man command, we do not know if the operation commands, we can help to see through the man command.
Command line mode simple C language compiler and linker and other operations
We can write a simple C language programs by vim editor, such as writing a program output own student number. Create a folder, then enter the newly created file folder.
The next four stages were compiled C language program: pre-compile, compile, assemble, link
a) pre-compiled
b) Compile
We can open the file with vim 15012214.s to view the content
c) compilation
By the objdump command to disassemble the file contents of the file
d) link
Also you need to use the command objdump to disassemble the file contents of the file
e) running
(3), multi-file compilation
We exp4 folder below to build a folder mfc (multi-fifiles compile)
In this folder create the following 5 files, file names are as follows:
Contents of each file are as follows:
(A) main.c file
(2) my1.h file
(3) my1.c file
(4) my2.h file
(5) my2.c file
Enter the code above is completed, then we compile, for multi-file compilation, we can compile links to an executable file, you can compile each C file separately, and finally get linked executable file.
Please explain the difference between the two methods?
第一种方法:一次编译链接直接生成可执行文件,不产生目标文件;
第二种方法:分别对每个C文件进行编译产生目标文件,之后再进行链接得到可执行文件
Next, we write a simple Makefile, by make tools to help us compile. Write a Makefile in the current folder
Enter the following within the Makefile:
Now we can make a direct input in the terminal can be compiled and linked operations: