LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1385|回复: 5

问:“库”和“头文件”的联系和区别?

[复制链接]
发表于 2006-12-9 22:39:20 | 显示全部楼层 |阅读模式
标题就是问题。

后辈对概念不是很清楚,请教各位前辈。

(前后辈不说指年龄上的,呵呵,不用说了吧,呵呵。。。。)
发表于 2006-12-9 23:02:53 | 显示全部楼层
头文件是编译器要用的,库是连接器要用的
库的头文件对库中导出的数据结构和类、函数进行说明
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-12-10 12:03:27 | 显示全部楼层
x11兄可否举例说说哪些是“库的头文件”,ld要用到库时,要导出你所说的“数据结构,类,和函数”么?具体是怎么样的?(x11兄有时间的话可以举个实例,呵呵)谢谢!
回复 支持 反对

使用道具 举报

发表于 2006-12-10 13:31:37 | 显示全部楼层
/usr/include/下,基本上都是库的头文件阿
随便找个例子,你看 man gettimeofday
GETTIMEOFDAY(2)            Linux Programmer’s Manual           GETTIMEOFDAY(2)

NAME
       gettimeofday, settimeofday - get / set time

SYNOPSIS
       #include <sys/time.h>
       #include <time.h>

       int gettimeofday(struct timeval *tv, struct timezone *tz);
       int settimeofday(const struct timeval *tv , const struct timezone *tz);

DESCRIPTION
       The functions gettimeofday() and settimeofday() can  get  and  set  the
       time  as  well  as a timezone.  The tv argument is a struct timeval (as
       specified  in <sys/time.h>):

         struct timeval {
             time_t      tv_sec;     /* seconds */
             suseconds_t tv_usec;    /* microseconds */
         };

       and gives the number of seconds and microseconds since the  Epoch  (see
       time(2)).  The tz argument is a struct timezone:

         struct timezone {
             int tz_minuteswest;     /* minutes west of Greenwich */
             int tz_dsttime;         /* type of DST correction */
         };

       If  either  tv or tz is NULL, the corresponding structure is not set or
       returned.

。。。
ld不是根据头文件来的,好像是根据.o文件中的符号信息来的
具体怎么来嘛,我也不知道阿,呵呵,有本书,http://www.iecc.com/linker/ 你读完应该就有答案了。不过我也没读过,哈哈
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-12-10 13:42:09 | 显示全部楼层
晕,我想点击你给出的网址,发现在Linux环境下要手动配置代理,很麻烦,请问x11兄有什么好建议,或给出(嘻嘻,现找到再给也可以)代理速度测试的代码。我知道我们学校计算机学院的一个学生他有源代码,编译后,可以运行测试某某网站提供的代理列表的速度,可是他“不会”给我。
回复 支持 反对

使用道具 举报

发表于 2006-12-10 20:56:59 | 显示全部楼层
我点了那个连接,都是英文的,半天找不到想看的,学英语!!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表