2009-05-06 21 views
3

ソケットを使用する単純なNetbeans Cプロジェクトをコンパイルすると、次のような出力が得られます。 問題は、gccがsockets.hライブラリを正しくリンクしていないことです。 これを解決するにはfoolprofメソッドが必要です。 おかげで私はあなたが適切な-lフラグが必要OpenSolaris 2008.11でgccでコンパイルするときに未解決のシンボル

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. 

答えて

10

を進めます。私はそれを探しています。

Duh。 -lsocketを追加します。実際には、おそらく-lnslが必要です。 this man pageを参照してください。

Netbeansでは、これはProject Propertiesにあるはずです。

4

リンカーがsocketnslのライブラリをリンクしていることを確認する必要があります。コマンドラインで、-lsocket -lnslを追加してください。私はnetbeansを知らないし、正確にそこで動作する方法を教えてくれませんが、どこかでこれらのライブラリを追加できるリンカ設定が必要です。

関連する問題