当前位置: 技术问答>linux和unix
无法编译成a.out文件
来源: 互联网 发布时间:2015-02-19
本文导语: 编译时,出现以下错误,我不懂为什么出错,以及怎么处理. unix编程学习很辛苦呢,相关资料又少,各位帮忙了,小弟多谢! 258$ cc uname.c undefined first referenced symbol ...
编译时,出现以下错误,我不懂为什么出错,以及怎么处理.
unix编程学习很辛苦呢,相关资料又少,各位帮忙了,小弟多谢!
258$ cc uname.c
undefined first referenced
symbol in file
gethostname uname.o
i386ld fatal: Symbol referencing errors. No output written to a.out
cat uname.c
#include
#include
#include
#ifndef MAXHOSTNAMELEN
#define MAXHOSTNAMELEN 256
#endif
main()
{
char hostname[MAXHOSTNAMELEN];
long hostid;
size_t size;
size= MAXHOSTNAMELEN;
if (gethostname(hostname,size) != 0)
{
printf("could not gethost name n");
exit(1);
}
hostid = gethostid();
printf("hostname=%snhostid=%dn",hostname,hostid);
}
unix编程学习很辛苦呢,相关资料又少,各位帮忙了,小弟多谢!
258$ cc uname.c
undefined first referenced
symbol in file
gethostname uname.o
i386ld fatal: Symbol referencing errors. No output written to a.out
cat uname.c
#include
#include
#include
#ifndef MAXHOSTNAMELEN
#define MAXHOSTNAMELEN 256
#endif
main()
{
char hostname[MAXHOSTNAMELEN];
long hostid;
size_t size;
size= MAXHOSTNAMELEN;
if (gethostname(hostname,size) != 0)
{
printf("could not gethost name n");
exit(1);
}
hostid = gethostid();
printf("hostname=%snhostid=%dn",hostname,hostid);
}
|
什么平台?什么编译器?
我的没有错误啊?!
我的没有错误啊?!