c - 在 OpenSolaris 2008.11 上使用 gcc 编译时未解析的符号

标签 c sockets gcc netbeans solaris

当编译一个使用套接字的简单 Netbeans C 项目时,我得到以下输出。 我想问题是 gcc 没有正确链接 sockets.h 库。 需要一个万无一失的方法来解决这个问题。

Running "/usr/bin/make  -f Makefile CONF=Debug clean" in /export/home/manu/Escritorio/TP-entrega 2/Application_1

/usr/bin/make -f nbproject/Makefile-Debug.mk SUBPROJECTS= .clean-conf
rm -f -r build/Debug
rm -f dist/Debug/GNU-Solaris-x86/application_1

Clean successful. Exit value 0.

Running "/usr/bin/make  -f Makefile CONF=Debug" in /export/home/manu/Escritorio/TP-entrega 2/Application_1

/usr/bin/make -f nbproject/Makefile-Debug.mk SUBPROJECTS= .build-conf
/usr/bin/make  -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Solaris-x86/application_1
mkdir -p build/Debug/GNU-Solaris-x86
rm -f build/Debug/GNU-Solaris-x86/tp2.o.d
gcc   -c -g -MMD -MP -MF build/Debug/GNU-Solaris-x86/tp2.o.d -o build/Debug/GNU-Solaris-x86/tp2.o tp2.c
mkdir -p dist/Debug/GNU-Solaris-x86
gcc    -o dist/Debug/GNU-Solaris-x86/application_1 build/Debug/GNU-Solaris-x86/tp2.o 

Undefined                        first referenced
 symbol                              in file

bind                                build/Debug/GNU-Solaris-x86/tp2.o

recv                                build/Debug/GNU-Solaris-x86/tp2.o

send                                build/Debug/GNU-Solaris-x86/tp2.o

accept                              build/Debug/GNU-Solaris-x86/tp2.o

listen                              build/Debug/GNU-Solaris-x86/tp2.o

socket                              build/Debug/GNU-Solaris-x86/tp2.o

ld: fatal: Symbol referencing errors. No output written to dist/Debug/GNU-Solaris-x86/application_1
collect2: ld returned 1 exit status
*** Error code 1
make: Fatal error: Command failed for target `dist/Debug/GNU-Solaris-x86/application_1'
Current working directory /export/home/manu/Escritorio/TP-entrega 2/Application_1
*** Error code 1
make: Fatal error: Command failed for target `.build-conf'
Current working directory /export/home/manu/Escritorio/TP-entrega 2/Application_1
*** Error code 1
make: Fatal error: Command failed for target `.build-impl'

Build failed. Exit value 1.

最佳答案

您需要适当的 -l 标志。我正在查找。

呃。添加-lsocket。实际上,您可能还需要 -lnsl。参见 this man page .

在 Netbeans 中,这应该在 Project Properties 中.

关于c - 在 OpenSolaris 2008.11 上使用 gcc 编译时未解析的符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/832296/

相关文章:

linux - 编译期间未使用对 GCC 规范文件的编辑

c - OS X 中的 POSIX API 是否需要比 Cocoa 更高的权限

选择一个已被使用的本地源端口

java - 编译 JVMTI 代理(使用 GCC,在 OSX Snow Leopard 上)

java - SocketException recv 失败,但为什么?

c - 为什么改变 SO_RCVBUF 的值不起作用?

gcc - 从cygwin64编译32位代码

c -/bin/ls程序从什么地址开始执行?

c - 了解添加到链接列表的前面

c - c中printf命令的顺序