GCC-header file/library file

Source: Internet
Author: User
how GCC looks for header files READMEAuthor: Wanri School: Chongqing University of Posts and telecommunications email:wlxing@yahoo.com GCC-header file

Note: If you encounter an inability to find the XXX header file, in general, the installation package is not fully installed (to install the dev package, such as Xxx-dev) caused.
This section is about how to query the corresponding header file when GCC compiles. Look down in order:
1. Default situation:
(1) header file Search will start with the-I parameter
(2) GCC environment variable C_include_path,cplus_include_path,objc_include_path
(3) Specify Directory directory

/usr/include
/usr/local/include
/usr/lib/gcc-lib/i386-linux/[Numeric number, such as 4.6]/include
/usr/lib/gcc-lib/ i386-linux/[number]/... /.. /.. /.. /include/g++-3
/usr/lib/gcc-lib/i386-linux/[number]/... /.. /.. /.. /i386-linux/include
Specified situation
Library file But if there's a given prefix when you install GCC, then it's
/usr/include
prefix/include
prefix/xxx-xxx-xxx-gnulibc/include
prefix/lib/gcc-lib/ Xxxx-xxx-xxx-gnulibc/2.8.1/include
GCC-Library files

(1) GCC is going to find-l
(2) GCC environment variable Library_path
(3) Specify the directory:

/usr/local/lib/
/usr/lib/
GCC-Dynamic librariesSearch Path
Method One: Specify a dynamic library search path in the configuration file/etc/ld.so.conf
Method Two: Specify the dynamic library search path through the environment variable Ld_library_path (when multiple dynamic library search paths are specified through the environment variable, the paths are separated by a colon ":")
Method Three: Specifies the dynamic library search path for the program when the target code is compiled (you can also specify the program's dynamic Library search path when compiling the target code). This is specified by the parameter "-wl,-rpath," of GCC. When multiple dynamic library search paths are specified, the paths are separated by a colon ":".
Four: Default dynamic library search path/lib
V: Default Dynamic Library search path/usr/lib search Order
The sequence of search paths for dynamic libraries is:
(1). The dynamic library search path specified when compiling the target code;
(2). Environment variable Ld_library_path the specified dynamic library search path;
(3). The dynamic library search path specified in the configuration file/etc/ld.so.conf;
(4). Default dynamic library search path/lib;
(5). The default dynamic library search path/usr/lib. other

Static libraries and dynamic libraries
(1) Static connection library is to the (Lib) file used in the function code directly linked to the target program, when the program is running, no other library files are needed; Dynamic linking is the file module (DLL) where the function is invoked, and the location of the calling function in the file, to the target program. When the program runs, it looks for the corresponding function code from the DLL, so it needs the support of the DLL file.
(2) Static link library and dynamic link library are the way to share the code, if the use of static link library, whether you want to, lib in the instructions are all directly included in the final generated EXE file. However, if you use a DLL, the DLL does not have to be included in the final EXE file, exe file execution can "dynamically" reference and uninstall this independent DLL file with EXE. Another difference between static and dynamic-link libraries is that there can be no more dynamic-link libraries or static libraries in the static link library, and other dynamic or static link libraries in the dynamic-link library.

header files and library files
(1) The header file is "interface", the library is "implementation", the header file has a function declaration, the library file implements the definition of the function.
(2) Library files are generally provided to users in the form of binary rather than C source files.
(3) header files end With. h, you can view the content in a text editor, ASCII. The library file ends with a. A (static library) or. So (dynamic library), which is binary.

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.