Getting Started with C language

 

A few keywords

Header file (ending in .h)

Source files ending with .c

Object files ending with .o

Three kinds of direct relationship

Source file references the header file, the source file production target file, the file header contains the function of the target file

Library file into static library and dynamic library, are as follows:

.a for static libraries

.so represents the dynamic library files

gcc -c  a.c b.c

Create a library file

ar crv libfoo.a a.o b.o

In some systems, the use of libraries to be successful, you need to generate a table of contents for the library, you can use ranlib order to complete this work. Of course, in linux, when you are using the GNU software development tools, you can omit this step.

ranlib libfoo.a

To generate an executable program

gcc -o program program.o libfoo.a

You can also use the -l option to access the library, but not saved in the standard location, you must use the -L option to tell the compiler where to find it.

-a -L gcc program.o the program. -lfoo

 

 

Published 66 original articles · won praise 8 · Views 140,000 +

Guess you like

Origin blog.csdn.net/gnufre/article/details/104574462