linux I (uppercase i) and L (uppercase l) l of Lowercase l

  • 2021-07-26 09:17:56
  • OfStack

As an entry-level user of linux, gcc/g++ Has been used many times, but sometimes a slightly more complex program will use the library. When I encountered problems, I checked a lot of information summarized by my predecessors, and also left a script hoping to help my friends. If I can also deal with your problems, I will feel very happy, hee hee.
For example: libz. so

g++ -o compress compress.cpp -I/home/include/ -L/lib/ -lz

(1)-I (capital i)

The compiler follows the path specified by-I to search for header files.

-I/home/include/ Indicates that the -I/home/include/ Directory is the first directory to look for header files, and the order of looking is:

/home/include/ -- > /usr/include-- > /usr/local/include

(2)-L (capital l)

Representation: The compiler follows the path specified by-L to find library files, and you can specify multiple library files with-l at one time after-L.

-L/lib/means looking for library files in the/lib/directory

(3)-l (lowercase l)

Represents: Compiler to the system default path search, if not found, to the current directory, if not found, to the current directory LD_LIBRARY_PATH Such as environment variables set to the top of the way to find, if still not found, then the compiler prompted not to find the library.

This example uses the gunzip library, the library file name is libz. so, and the library name is z. It is easy to see that removing the header lib and the tail. so of the library file name is the library name.

Summarize


Related articles: