【发布时间】:2011-03-06 07:15:57
【问题描述】:
1.为什么我们需要链接非标准库/包含非标准头文件,而它们已经存在于正确的文件夹中
anirudh@anirudh-Aspire-5920:~/Documents/DUMP$ locate libpthread
/lib/libpthread-2.12.1.so
/lib/libpthread.so.0
/usr/lib/libpthread.a
/usr/lib/libpthread.so
/usr/lib/libpthread_nonshared.a
/usr/lib/xen/libpthread.a
/usr/lib/xen/libpthread_nonshared.a
anirudh@anirudh-Aspire-5920:
ld.so/ld-linux.so - dynamic linker/loader 的手册页说搜索了程序所需的必要库In the default path /lib, and then /usr/lib.
当我的库的 .so 文件已经存在于 /lib 文件夹中时,为什么我需要专门链接它。
-l 选项也用于链接静态库。但是当我对进程执行 pmap 时,我看到正在使用扩展名为 .so 的 pthread 动态库,而不是扩展名为 .a 的动态库。
同样
anirudh@anirudh-Aspire-5920:~/Documents/DUMP$ locate mysql.h
/usr/include/mysql/mysql.h
anirudh@anirudh-Aspire-5920:~/Documents/DUMP$
当它已经存在于文件夹/usr/include 中,这是所有头文件的标准文件夹,那么为什么我需要使用-I 选项专门包含它。
【问题讨论】:
标签: c linux gcc dynamic-linking static-linking