[英]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_PATH
和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? pkg-config
和LD_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_PATH
和ld.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.