LINUX System header file and library file search path __linux

Source: Internet
Author: User

Include header file, link database, System definition, total of the following sources specify GCC go there and find it.

Originally specified at compile time (in ~gcc/gcc/collect2.c:locatelib ()

Written in specs.

Later with-d-i-L specified

GCC environment variable settings (at compile time)

ld.so environment variable (this is run time)

I. Header documents

How does GCC find the required header files at compile time:

※ All header file searches will start with-I

※ then find GCC's environment variable C_include_path,cplus_include_path,objc_include_path

※ Find the default catalogue again

/usr/include

/usr/local/include

/usr/lib/gcc-lib/i386-linux/2.95.2/include

/usr/lib/gcc-lib/i386-linux/2.95.2/.. /.. /.. /.. /include/g-3

/usr/lib/gcc-lib/i386-linux/2.95.2/.. /.. /.. /.. /i386-linux/include

But if there is a given prefix when GCC is installed, then it is

/usr/include

Prefix/include

Prefix/xxx-xxx-xxx-gnulibc/include

Prefix/lib/gcc-lib/xxxx-xxx-xxx-gnulibc/2.8.1/include

Second, the library document

The options for function libraries such as cos () should be-LM

Compile the time:

※GCC will find L.

※ Find GCC's environment variable Library_path

※ Find the default directory/lib/usr/lib/usr/local/lib This is the original compile GCC written in the program

Third, the Run-time Dynamic Library search path (in the order of search)

1. Specify the dynamic library search path for the program when compiling the target code (you can also specify the program's dynamic Library search path when compiling the target code).

2, through the environment variable ld_library_path specified dynamic library search path (when you specify multiple dynamic library search paths through this environment variable, the paths are separated by a colon ":")

3. Specify the dynamic library search path in the configuration file/etc/ld.so.conf

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 ":".

4, the default dynamic library search path/lib

5, the default dynamic library search path/usr/lib

Original address: http://blog.csdn.net/lily854212198/article/details/8060377

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.