ldd:
/etc/ld.so.conf.d
pkg-config: locate pkgconfig for managed lib
check the gcc include path:
echo | cpp -Wp,-v
or short cpp -v
or gcc -xc -v – (for c), gcc -xc++ -v – (for c++)
ldconfig is used to find the shared library when executing a program
ldconfig search the /etc/ld.so.conf which then defines the searching path
LD_LIBRARY_PATH is used to specify the search path
add addtional include path:
export C_INCLUDE_PATH=/opt/local/include
export CPLUS_INCLUDE_PATH=/opt/local/include
add addtional library path
export LIBRARY_PATH=/opt/local/lib
搜索的先后顺序是:
1.编译目标代码时指定的动态库搜索路径;
2.环境变量LD_LIBRARY_PATH指定的动态库搜索路径;
3.配置文件/etc/ld.so.conf中指定的动态库搜索路径;
4.默认的动态库搜索路径/lib;
5.默认的动态库搜索路径/usr/lib。
CPATH
C_INCLUDE_PATH
CPLUS_INCLUDE_PATH
OBJC_INCLUDE_PATH
find the which header files are included:
gcc -M main.cpp -I/opt/local/include
ignore the system header files:
gcc -M main.cpp
or gcc -H main.cpp
linux:
sudo ldconfig (will refresh the ldconfig’s cache)
ldconfig -p: list all managed lib (/etc/ld.so.conf)
ldconfig -n /opt/dummy/lib #add new lib to ldconfig links, may not permantly
ldd APP: to show its linked lib
if ldd APP found “not found XX”, this may cause by ldconfig, which is called by ldd
pkg-config –cflags –libs libass
echo $PKG_CONFIG_PATH together with /usr/lib/pkgconfig, /usr/share/pkgconfig, /usr/local/lib/pkgconfig and /usr/local/share/pkgconfig
gcc program.c $(pkg-config –cflags –libs gnomeui)
CMake Module path
/usr/share/cmake-3.5/Modules
find the head file:
echo ‘#include <stdbool.h>’ | cpp -H
or: locate stdbool.h
locate
sudo updatedb to refresh locate cache
mac osx
otool -L APP # ldd’s equipvalent
or dyldinfo -dylibs APP
查看.a文件都包含了那些文件
ar -t xxx.a
查看.so文件接口
nm -D xxx.so
查看库支持的CPU体系结构
readelf -h libxslt.a/so
ffmepg:
–extra-libs=’/usr/local/lib/libTransform360.a -lstdc++ -L/usr/local/lib’