這是我第一次OpenSSL的插座程序未定義參考err_exit,OpenSSL中的socket編程berr_exit..etc在Ubuntu
請參閱本link
首先我-g GCC編譯服務器。 ç-o服務器
,但得到這個錯誤
/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5.2/../../../crt1.o:功能
_start': (.text+0x18): undefined reference to
主' /tmp/ccxiY18C.o :功能tcp_listen': /home/usr/Desktop/c-examples/server.c:11: undefined reference to
err_exit' /home/usr/Desktop/c-examples/server.c:20:undefined reference toberr_exit' /tmp/ccxiY18C.o: In function
load_dh_params': /home/usr/Desktop/c-examples/server.c:33:undefined參考BIO_new_file' /home/usr/Desktop/c-examples/server.c:34: undefined reference to
berr_exit' /home/usr/Desktop/c-examples/server.c:36:undefined reference toPEM_read_bio_DHparams' /home/usr/Desktop/c-examples/server.c:37: undefined reference to
BIO_free' /home/usr/Desktop/c-examples/server.c:38:undefined reference toSSL_CTX_ctrl' /home/usr/Desktop/c-examples/server.c:39: undefined reference to
berr_exit' /tmp/ccxiY18C.o:功能generate_eph_rsa_key': /home/usr/Desktop/c-examples/server.c:47: undefined reference to
RSA_generate_key' /home/usr/Desktop/c-examples/server.c:49 :未定義參照SSL_CTX_ctrl' /home/usr/Desktop/c-examples/server.c:50: undefined reference to
berr_exit ' /home/usr/Desktop/c-examples/server.c:52:未定義參考`RSA_free'
然後i相GCC -g server.c編譯它 - O服務器-lssl -lcrypt
它給
/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5.2/../../ .. /crt1.o:功能
_start': (.text+0x18): undefined reference to
主' /tmp/ccPlisKL.o:功能tcp_listen': /home/usr/Desktop/c-examples/server.c:11: undefined reference to
err_e xit' /home/usr/Desktop/c-examples/server.c:20:undefined reference toberr_exit' /tmp/ccPlisKL.o: In function
load_dh_params': /home/usr/Desktop/c-examples/server.c:34:undefined reference toberr_exit' /home/usr/Desktop/c-examples/server.c:39: undefined reference to
berr_exit ' /tmp/ccPlisKL.o:在功能generate_eph_rsa_key': /home/usr/Desktop/c-examples/server.c:50: undefined reference to
berr_exit' collect2:LD返回1個退出狀態
我怎樣才能解決這個問題..請給我一個解決方案..