简体   繁体   中英

Difference about pkg-config and LD_LIBRARY_PATH

I am trying to understand the compile and link process in C++ on Ubuntu.

From what I've learned, pkg-config is usually used to extract metadata defined in .pc file through PKG_CONFIG_PATH , then to locate the include and library file needed when compiling and linking.

My question is since we already have pkg-config , why do we bother using LD_LIBRARY_PATH and ld.so.conf ? Does pkg-config and LD_LIBRARY_PATH have different use (I know LD_LIBRARY_PATH has a higher priority than ld.so.conf ), or is LD_LIBRARY_PATH used for the situation when there is no .pc file, or is it just this priority thing?

LD_LIBRARY_PATH and ld.so.conf are used to locate shared libraries at run time, when program is started by the loader ( ld.so ). pkg-config files instead contain compiler/linker flags ( -I , -L , -l , etc.) needed to build program that uses particular library (eg locate linked shlibs via -Lpath ).

Also note that many libraries lack .pc configs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM