Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Detailed explanation of the function of-I (uppercase I) and-L (uppercase l)-l (lowercase l) when compiling program under linux

2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

As a linux entry-level user, gcc/g++ 's simple operations have been used many times, but sometimes slightly more complex programs use libraries. When I encountered problems, I checked a lot of information summarized by my predecessors, and left a script hoping to be helpful to my friends. If I can also deal with your problems, I will feel very happy, hee hee.

For example: libz.so

Gmail +-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 the header file.

-I/home/include/ means to use the-I/home/include/ directory as the first directory to look for header files in the following order:

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

(2)-L (capital l)

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

-L/lib/ means to look for library files in the / lib/ directory

(3)-l (lowercase l)

Compiler to the system default path search, if not found, to the current directory, if the current directory can not be found, then to the LD_LIBRARY_PATH and other environment variables on the top of the path to find, if not found, then the compiler prompt can not find the library.

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

Summary

At this point, this is the end of this article on the role of-I (uppercase I) and-L (uppercase l)-l (lowercase l) when compiling under linux. Please search the previous articles or continue to browse the relevant articles below for more information about the content of the linux glossy + compiler. I hope you will support it in the future!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report