Http://www.cnblogs.com/4925278/archive/2012/11/28/gcc-gdb-make-makefile.html
Gcc-GDB-make-makefile
1. During GCC program compilation, the compilation and connection processes can be divided into four phases:
Preprocessing(Pre-processing)
Compile(Compiling)
Assembly(Grouping)
Connection(Linking)
2. GCC uses the file suffix to differentiate the type of the input file:
(1) Use. CFile with a suffix: C source code file.
(2).File with a suffix: it
commands will not be searched and executed again.
Ii. Make usage:
1. Make is just a command. It must be used with a file named makefile. The MAKEFILE file describes the rules for compiling links of the entire project. For example, which source files in the project need to be compiled and how to compile, which library files need to be created, and how to create library files?
2.
I have been learning how to write makefile recently. When we write a small number of program files, we should input gcc/g ++. When you compile files one by one in a large project, you may be very depressed. Linux has a built-in make command, which saves your work a lot of effort, but you need to learn how to compile makefile files.Makefile is a special file format that will help you automatically manage you
Automatic generation of ProjectMakefilefileTheoretical basisWrite makefile:http://bbs.chinaunix.net/forum.php?mod=viewthreadtid=408225 with me.Cases Urealyticum autoconf and Automake generating Makefile files: http://www.ibm.com/developerworks/cn/linux/l-makefile/index.htmlSteps
Write the makefile.am .
Run AutoScan, automatically create two files: autoscan.log Configure.scan
Name the configure.scan
Now the IDE environment is mostly highly integrated, only need to press a button to complete the compilation-assembly-link work, but in the process of embedded development, need to write according to the actual needs of the individual needs, which need to master the makefile. The convenience of the advanced IDE is based on makefile, and makefile is actually a
Makefile and makefile are equivalent.
$ MV makefile
$ Make
Gcc-C main. c
Gcc-C Liu. c
Gcc-C generatedatafile. c
Gcc-G main. O Liu. O generatedatafile. O-o Liu
-L/usr/local/MySQL/lib/MySQL-lmysqlclient-LZ
Rm-f *. o
Makefile format
Depend
MAKEFILE file format
0. PrefaceFrom the beginning of learning C language began to contact Makefile, consulted a lot of makefile information but always feel no real master makefile, if you write a makefile always feel very laborious. So deliberately using the blog to summarize the relevant knowledge of
The variable defined in makefile, like a macro in the C + + language, represents a text string that, when executed in makefile, automatically expands to the original mode as it is used. It differs from C/s + + in that you can change its value in makefile. In makefile, variables can be used in "targets", "dependent targ
Please write a makefile at the same time compile, link the following two programs:
MAIN1.C:
#include
int main (void)
{
printf ("main1\n");
}
MAIN2.C:
#include
int main (void)
{
printf ("main2\n");
}
"Analysis": Here you need to generate two executables main1 and main2 (two destinations). Since makefile can only have one target, it is possible to construct an ultimate goal all with no rules and rely on
Makefile is used for compiling the entire project under Linux, which is very important for the compiler of C/s + + language under Linux.
This paper takes the practical C source program as an example, introduces how to use makefile to compile the C language project under Linux, which provides a reference for the development of related work.
One, what is makefile
This is a creation in
Article, where the information may have evolved or changed.
I've been using Golang for a while, and during the development of Golang, I've been used to repeatedly manually execute go build and both go test commands. But now I'm out of this habit. If you only use simple commands without parameters, it may not be scary to do so directly. But in some complex tasks, if it's still manual execution go build go test , it can be a headache.
We can solve this problem by other means.
What is makefile?The role of Makefile:1, the project document organization, compiles the complex procedure2. Install and uninstall our programMakefile Use ExampleThe following three files are available in the/home/username/makefile directory:Main.c
#include
#include
int main (int argc, char *argv[]) {
int x, y;
SSCANF (argv[1], "%u", x);
SCC
############## Truly execute actions !!!!!! ####################PHONY + = $ (vmlinux-dirs) # pseudo target$ (Vmlinux-dirs): prepare scripts$ (Q) $ (MAKE) $ (build) =$ @# (1) build =-f scripts/Makefile. build obj = # It is equivalent to make-f scripts/Makefile. build obj =$ @# In Makefile. build, the first true dependency rule is _ build. In line 93, we enter here
Make is a very important compilation command in both Linux and UNIX environments. Make or make install is often used for project development and application software installation. With the make tool, we can break down large development projects into multiple modules that are easier to manage. For an application that includes hundreds of source files, by using make and makefile, You can streamline the complex relationships between various source files.
In the previous section, we introduced two methods for driver entry into the kernel: module and direct compilation into the kernel, and introduced the module'sOne way to compile: In an independent folder, use makefile with the kernel source code path.
So how to directly compile the driver into the kernel?
What is kernel pruning that we often hear about during kernel porting configuration?
We often execute the make menuconfig command during Linux Kerne
Learning makefile at the beginning is a painful process. From chaotic rules to a simple makefile and then to a systematic makefile is not a one-stop process. TodayI will write a simple, standardized (relatively speaking) makefile with complete functions. Makefile for beginne
kernel modules, the connection process, and the writing of makefile have changed.2.4 Kernel, the module compiles only the kernel source dock file, need to define module before including Linux/modules.h, the kernel module suffix that is generated after compiling and connecting is. O.2.6 Kernel, the module's compilation needs to be configured the kernel source code; The kernel module suffix generated after compiling and connecting is. Ko; the compilati
will write makefile from the side can reflect whether a person has the ability to complete large-scale projects, although I am only a slag, but I love learning Ah, 650) this.width=650; "Src=" http ://img.baidu.com/hi/jx2/j_0013.gif "alt=" j_0013.gif "/> So .... So let's talk about the basic operation and usage of make and makefile files today.A Makefile is a fil
Linux application Development-makefile a MakefileProject management files, compiled into complex programsAssembly procedureTwo rules1 file name: All lowercase makefile or first letter makefile uppercase, others are not 2 inside the file # represents the commentThree writing Makefile is made up of many rules.Rules: D
Changhong Sword Own Some experience summary, specific please decide according to the actual situation.(not finished and to be added to the details)-A Makefile template was added in 2016-10-25-In 2016-10-27, CMake and CMake generation NMAKE were added to organize the compiled directories under Windows to help understand the VS x86 and x64 compilation process.-2017-6-7 added a gcc option, about library dependency order Preface
Whether on Windows or Linu
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.