Experiment 4 Linux system to build a C language programming environment
project | content |
---|---|
This work belongs courses | < Home link classroom courses > |
Where this requirement in the job | <Link then address operational requirements> |
Student ID - Name | 17043214- river fluttering |
Job learning objectives | 1, the Linux System C language development environment to build 2, learning Linux system environment C language development process |
1. Install the C language development environment
Check the version information of gcc
View make version information
2. A simple C language exercises
1) First, we help documentation through the man command
If we do not know the operation commands, we can help to see through the man command. Such as:
2) a simple command-line mode 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.
We finished the input source, then we were four stages of C language program is compiled, pre-compiled, compiler, assembler, linker
a) pre-compiled
We can open the file with vim test.i to view the contents of the file, you can also use the command to view
b) Compile
We can open the same file with vim test.s to view the content, you can also use commands such as cat
Because precompiled and compiled the resulting file is a text file, so we can view the contents of the file to open with vim.
c) compilation
Generated here than text files, binary files, we can disassemble the file by objdump command to analyze the contents of the file
d) link
Executable files are binary files, also 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-files compile)
In this folder create the following 5 files, file names are as follows:
Contents of each file are as follows:
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?
A: multi-file compilation, a compiler can generate links to executable files; single-file compiled separately for each C files are compiled, then linked again to get an executable file.
Next, we write a simple Makefile, by make tools to help us compile. Write a Makefile in the current folder
Now we can make a direct input in the terminal can be compiled and linked operation