不同gcc环境下的C编译错误
C Compiling Error on different gcc environment
我的 C 程序在 Ubuntu gcc 上编译正常,但在 Solari 上有一个错误:
gcc dhtserver.o map.o -o dhtserver -Wall
Undefined first referenced
symbol in file
bind dhtserver.o
getsockname dhtserver.o
accept dhtserver.o
listen dhtserver.o
gethostbyname dhtserver.o
sendto dhtserver.o
socket dhtserver.o
connect dhtserver.o
recvfrom dhtserver.o
inet_pton dhtserver.o
inet_ntop dhtserver.o
ld: fatal: symbol referencing errors. No output written to dhtserver
collect2: ld returned 1 exit status
为什么会出现符号引用错误?
Solari gcc version:4.2.1 Ubuntu:4.8.1
Solaris 是(曾经是?)SYSV。传统上,这希望向链接器明确提及套接字库。尝试链接:-lsocket -lnsl
.
我的 C 程序在 Ubuntu gcc 上编译正常,但在 Solari 上有一个错误:
gcc dhtserver.o map.o -o dhtserver -Wall
Undefined first referenced
symbol in file
bind dhtserver.o
getsockname dhtserver.o
accept dhtserver.o
listen dhtserver.o
gethostbyname dhtserver.o
sendto dhtserver.o
socket dhtserver.o
connect dhtserver.o
recvfrom dhtserver.o
inet_pton dhtserver.o
inet_ntop dhtserver.o
ld: fatal: symbol referencing errors. No output written to dhtserver
collect2: ld returned 1 exit status
为什么会出现符号引用错误? Solari gcc version:4.2.1 Ubuntu:4.8.1
Solaris 是(曾经是?)SYSV。传统上,这希望向链接器明确提及套接字库。尝试链接:-lsocket -lnsl
.