在OpenSolaris 2008.11上使用gcc编译时未解决的符号

时间:2022-09-07 07:34:06

When compiling a simple Netbeans C project that uses sockets I get the following output. I supose the problem is that gcc is not properly linking sockets.h library. Need a foolprof method to solve this. Thanks i advance

当编译使用sockets的一个简单的Netbeans C项目时,我得到了下面的输出。我认为问题是gcc没有正确地连接套接字。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.

2 个解决方案

#1


10  

You need the appropriate -l flag. I'm looking it up.

你需要合适的-l标志。我查找。

Duh. add -lsocket. Actually, you probably need -lnsl too. See this man page.

咄。添加-lsocket。实际上,你可能也需要-lnsl。看到这个男人页面。

In Netbeans this should be in the Project Properties.

在Netbeans中,这应该在项目属性中。

#2


4  

You need to make sure that the linker is linking the socket and nsl libraries. At the command line you would add -lsocket -lnsl to do so. I don't know netbeans and can't tell you how it works there exactly, but somewhere there should be linker settings where you can add these libraries.

您需要确保链接器正在链接套接字和nsl库。在命令行中,您将添加-lsocket -lnsl。我不知道netbeans,也不能确切地告诉您它是如何工作的,但是在某个地方应该有链接器设置,您可以在其中添加这些库。

#1


10  

You need the appropriate -l flag. I'm looking it up.

你需要合适的-l标志。我查找。

Duh. add -lsocket. Actually, you probably need -lnsl too. See this man page.

咄。添加-lsocket。实际上,你可能也需要-lnsl。看到这个男人页面。

In Netbeans this should be in the Project Properties.

在Netbeans中,这应该在项目属性中。

#2


4  

You need to make sure that the linker is linking the socket and nsl libraries. At the command line you would add -lsocket -lnsl to do so. I don't know netbeans and can't tell you how it works there exactly, but somewhere there should be linker settings where you can add these libraries.

您需要确保链接器正在链接套接字和nsl库。在命令行中,您将添加-lsocket -lnsl。我不知道netbeans,也不能确切地告诉您它是如何工作的,但是在某个地方应该有链接器设置,您可以在其中添加这些库。