Gcc compiler learning-general Linux technology-Linux programming and kernel information. The following is a detailed description. 1. Use gcc
Gcc compilation process:
1 preprocessing
The-E parameter allows gcc to stop the compilation process after preprocessing.
Gcc-E hello. c-o hello. I
2 compile
Use the-c parameter to compile the pre-processed source file into the target code.
Gcc-c hello. I-o hello. o
3 links
Link the generated target code to the class execution file.
Gcc hello. o-o hello
Ii. gcc warning function
Use the-Wall parameter to generate as many warnings as possible for gcc.
Gcc-Wall hello. c-o hello
Use the-Werror parameter to make gcc treat warnings as error handling.
Gcc-Werror hello. c-o hello
Iii. Library dependency
You can use the-I parameter to add a new directory to the gcc header file search path.
Gcc hello. c-I/home/wuzhiguo/include-o hello
You can use the-L parameter to add a new directory to the gcc library file search path.
Gcc hello. c-L/home/wuzhiguo/lib-l mylib-o hello
-L mylib indicates gcc to link the library file libmylib. so. The library files in Linux have a convention that all begin with lib, so you can save lib.
Dynamic library: End of. so, loaded at runtime.
Static Library: End of. a, which is loaded at compilation.
By default, gcc preferentially loads the dynamic library. You can use the-static option to force the static Link Library.
Gcc hello. c-L/home/wuzhiguo/lib-static-l mylib-o hello
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.