我的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版本:4.2.1 Ubuntu:4.8.1
最佳答案
Solaris是(以前是)SYSV。传统上,这是想让链接器明确提及套接字库。尝试链接:-lsocket -lnsl
。