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 < Operational requirements of the Home link >
Student ID - Name 17043103- Li Xiaofang
Job learning objectives 1. Understand the Linux system C language programming environment 2. The learning Linux C language development environment steps

1. Install the C language development environment

sudo apt install build-essential 

View gcc version information

gcc -v

View make version information

make -v

2. A simple C language exercises
1) First, we help documentation through the man command

man gcc

2) a simple command-line mode C language compiler and linker and other operations

Input source

a) pre-compiled

b) Compile

Open the file with vim test.s to view the content

c) compilation

d) link

After the executable file with the command objdump to disassemble the file

objdump -d test

File contents in the main function part

e) running

3) multi-file compilation

In 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:




Completion of the above code is entered, then compiled, 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.

Q: Please explain the difference between the two methods?

A: The two methods compared to the time needed to compile all linked files when the executable file to re-compile, and compile each file separately can recompile only modified files, unmodified files without recompiling.

Then write a simple Makefile, compiled by the make tool. Write a Makefile in the current folder

document content:

Directly at the terminal input make can be compiled and linked operation

Guess you like

Origin www.cnblogs.com/yilxf/p/12575904.html