简体   繁体   English

关于pkg-config和LD_LIBRARY_PATH的区别

[英]Difference about pkg-config and LD_LIBRARY_PATH

I am trying to understand the compile and link process in C++ on Ubuntu. 我试图了解Ubuntu上C ++中的编译和链接过程。

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. 据我了解, pkg-config通常用于通过PKG_CONFIG_PATH提取.pc文件中定义的元数据,然后找到编译和链接时所需的包含和库文件。

My question is since we already have pkg-config , why do we bother using LD_LIBRARY_PATH and ld.so.conf ? 我的问题是,因为我们已经有了pkg-config ,为什么还要麻烦使用LD_LIBRARY_PATHld.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? pkg-configLD_LIBRARY_PATH用法是否有所不同(我知道LD_LIBRARY_PATH的优先级高于ld.so.conf ),或者在没有.pc文件的情况下使用LD_LIBRARY_PATH还是仅仅是此优先级?

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 ). 当加载程序( ld.so )启动程序时,使用LD_LIBRARY_PATHld.so.conf在运行时定位共享库。 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 ). pkg-config文件而是包含编译器/链接器标志( -I-L-l等),用于构建使用特定库的程序(例如,通过-Lpath找到链接的-Lpath )。

Also note that many libraries lack .pc configs. 另请注意,许多库缺少.pc配置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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