当前位置: 技术问答>linux和unix
怎么判断需要连接 什么库 用 -l
来源: 互联网 发布时间:2016-08-29
本文导语: ?用什么命令 或者看头文件 就知道 gcc -MM -M的一大堆 不知道这个有没有必然联系。 目前只了解 用thread 可能要用 -lpthread 编译。。别的就不懂了。。贴几个 header 高手帮忙看看。。谢了 #include #include...
?用什么命令 或者看头文件
就知道 gcc -MM -M的一大堆 不知道这个有没有必然联系。
目前只了解 用thread 可能要用 -lpthread 编译。。别的就不懂了。。贴几个 header 高手帮忙看看。。谢了
就知道 gcc -MM -M的一大堆 不知道这个有没有必然联系。
目前只了解 用thread 可能要用 -lpthread 编译。。别的就不懂了。。贴几个 header 高手帮忙看看。。谢了
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
|
除了你自己的代码,其他调用的方法都是外部来的,都来自动态链接库
但是gcc默认已经帮你-lc了,就是已经链接了libc,多数你要调用的方法都在libc里。
其它的就靠经验了,比如-lm 是算术运算的so
随便一个编译好的程序,你用ldd 看一下,就知道它链接了哪些库
但是gcc默认已经帮你-lc了,就是已经链接了libc,多数你要调用的方法都在libc里。
其它的就靠经验了,比如-lm 是算术运算的so
随便一个编译好的程序,你用ldd 看一下,就知道它链接了哪些库
|
使用Solaris的man.
在t1000.unix-center.net申请一个帐号就可以了。
或者查看FreeBSD的在线手册。
比如查看pthread_create
http://www.freebsd.org/cgi/man.cgi?query=pthread_create&apropos=0&sektion=0&manpath=SunOS+5.10&format=html
Standard C Library Functions pthread_create(3C)
NAME
pthread_create - create a thread
SYNOPSIS
cc -mt [ flag... ] file... -lpthread [ library... ]
#include
int pthread_create(pthread_t *restrict thread, const
pthread_attr_t *restrict attr, void
*(*start_routine)(void*), void *restrict arg);
Networking Services Library Functions gethostbyname(3NSL)
NAME
gethostbyname, gethostbyname_r, gethostbyaddr,
gethostbyaddr_r, gethostent, gethostent_r, sethostent,
endhostent - get network host entry
SYNOPSIS
cc [ flag... ] file... -lnsl [ library... ]
#include
struct hostent *gethostbyname(const char *name);
在t1000.unix-center.net申请一个帐号就可以了。
或者查看FreeBSD的在线手册。
比如查看pthread_create
http://www.freebsd.org/cgi/man.cgi?query=pthread_create&apropos=0&sektion=0&manpath=SunOS+5.10&format=html
Standard C Library Functions pthread_create(3C)
NAME
pthread_create - create a thread
SYNOPSIS
cc -mt [ flag... ] file... -lpthread [ library... ]
#include
int pthread_create(pthread_t *restrict thread, const
pthread_attr_t *restrict attr, void
*(*start_routine)(void*), void *restrict arg);
Networking Services Library Functions gethostbyname(3NSL)
NAME
gethostbyname, gethostbyname_r, gethostbyaddr,
gethostbyaddr_r, gethostent, gethostent_r, sethostent,
endhostent - get network host entry
SYNOPSIS
cc [ flag... ] file... -lnsl [ library... ]
#include
struct hostent *gethostbyname(const char *name);
|
在实践中锻炼吧。
最近几天在看《深入理解计算机系统》的链接那章,很有收获,原来没那看明白。
LZ也可以看看。
最近几天在看《深入理解计算机系统》的链接那章,很有收获,原来没那看明白。
LZ也可以看看。
|
《深入理解计算机系统》
据说是理解计算机系统的经典之作!
据说是理解计算机系统的经典之作!
|
不懂的,就去网上查查,一查就有~~~多查几次就明白了。。。