unix gcc编译报错Symbol referencing errors. No output written to test

时间:2022-08-11 01:59:47

编译成.o文件时没错,链接这几个.o文件时,报错

inet_pton                           testserver.o  (symbol belongs to implicit dependency /usr/lib/libnsl.so.1)
inet_ntoa                           fun.o  (symbol belongs to implicit dependency /usr/lib/libnsl.so.1)


原因是它不认识里面的函数inet_pton和inet_ntoa,需要加入相应的静态库,这个库它已经提示你了,symbol belongs to implicit dependency /usr/lib/libnsl.so.1,所以编译时要在命令里加入:-lnsl

OK了。