当前位置: 技术问答>linux和unix
ssl链接问题
来源: 互联网 发布时间:2016-03-23
本文导语: 自己刚学makefile 其中源文件名字如下: CDnsQuery.cpp CHttpClient3.h CMutex.h CRespHeader2.cpp CTime.h netinc.h Utils.h CDnsQuery.h CHttpSession2.cpp CReqHeader.cpp CRespHeader2.h main.cpp CHttpC...
自己刚学makefile
其中源文件名字如下:
CDnsQuery.cpp CHttpClient3.h CMutex.h CRespHeader2.cpp CTime.h netinc.h Utils.h
CDnsQuery.h CHttpSession2.cpp CReqHeader.cpp CRespHeader2.h main.cpp
CHttpClient3.cpp CHttpSession2.h CReqHeader.h CTime.cpp Makefile Utils.cpp
然后我写了个Makefile 如下所示:
1 edit:main.o CDnsQuery.o CHttpClient3.o CHttpSession2.o
2 CReqHeader.o CRespHeader2.o CTime.o Utils.o
3 g++ -o edit main.o CDnsQuery.o CHttpClient3.o CHttpSession2.o
4 CReqHeader.o CRespHeader2.o CTime.o Utils.o
5 main.o:main.cpp CHttpClient3.h
6 g++ -c main.cpp
7 CDnsQuery.o:CDnsQuery.cpp netinc.h
8 g++ -c CDnsQuery.cpp
9 CHttpClient3.o:CHttpClient3.cpp CTime.h
10 g++ -c CHttpClient3.cpp
11 CHttpSession2.o:CHttpSession2.cpp netinc.h CDnsQuery.h CMutex.h
12 g++ -c CHttpSession2.cpp -L/usr/local/ssl/lib -lssl
13 CReqHeader.o:CReqHeader.cpp
14 g++ -c CReqHeader.cpp
15 CRespHeader2.o:CRespHeader2.cpp
16 g++ -c CRespHeader2.cpp
17 CTime.o:CTime.cpp Utils.h
18 g++ -c CTime.cpp
19 Utils.o:Utils.cpp
20 g++ -c Utils.cpp
21
22 clean:
23 rm edit main.o CDnsQuery.o CHttpClient3.o CHttpSession2.o
24 CReqHeader.o CRespHeader2.o CTime.o Utils.o
编译时出现如下错误:
CHttpSession2.o: In function `CHttpSession::Disconnect()':
CHttpSession2.cpp:(.text+0x55): undefined reference to `SSL_shutdown'
CHttpSession2.cpp:(.text+0x66): undefined reference to `SSL_free'
CHttpSession2.o: In function `CHttpSession::ReadWithSSL(char*, int)':
CHttpSession2.cpp:(.text+0x170): undefined reference to `SSL_read'
CHttpSession2.o: In function `CHttpSession::NewSession()':
CHttpSession2.cpp:(.text+0x657): undefined reference to `SSL_new'
CHttpSession2.cpp:(.text+0x692): undefined reference to `SSL_set_fd'
CHttpSession2.cpp:(.text+0x6ac): undefined reference to `SSL_free'
CHttpSession2.o: In function `CHttpSession::Connect()':
CHttpSession2.cpp:(.text+0x77f): undefined reference to `SSL_connect'
CHttpSession2.o: In function `CHttpSession::WriteWithSSL(char const*, int)':
CHttpSession2.cpp:(.text+0x857): undefined reference to `SSL_write'
CHttpSession2.o: In function `CHttpSession::SSLCleanup()':
CHttpSession2.cpp:(.text+0xa9f): undefined reference to `CRYPTO_set_locking_callback'
CHttpSession2.cpp:(.text+0xafb): undefined reference to `SSL_CTX_free'
CHttpSession2.o: In function `CHttpSession::InitSSL()':
CHttpSession2.cpp:(.text+0xb25): undefined reference to `SSL_library_init'
CHttpSession2.cpp:(.text+0xb2a): undefined reference to `OPENSSL_add_all_algorithms_noconf'
CHttpSession2.cpp:(.text+0xb2f): undefined reference to `SSLv23_client_method'
CHttpSession2.cpp:(.text+0xb37): undefined reference to `SSL_CTX_new'
CHttpSession2.cpp:(.text+0xb41): undefined reference to `RAND_poll'
CHttpSession2.cpp:(.text+0xb75): undefined reference to `RAND_seed'
CHttpSession2.cpp:(.text+0xb7a): undefined reference to `RAND_status'
CHttpSession2.cpp:(.text+0xb88): undefined reference to `CRYPTO_num_locks'
CHttpSession2.cpp:(.text+0xbf7): undefined reference to `CRYPTO_set_id_callback'
CHttpSession2.cpp:(.text+0xc03): undefined reference to `CRYPTO_set_locking_callback'
collect2: ld returned 1 exit status
make: *** [edit] Error 1
忘指点 谢谢
其中源文件名字如下:
CDnsQuery.cpp CHttpClient3.h CMutex.h CRespHeader2.cpp CTime.h netinc.h Utils.h
CDnsQuery.h CHttpSession2.cpp CReqHeader.cpp CRespHeader2.h main.cpp
CHttpClient3.cpp CHttpSession2.h CReqHeader.h CTime.cpp Makefile Utils.cpp
然后我写了个Makefile 如下所示:
1 edit:main.o CDnsQuery.o CHttpClient3.o CHttpSession2.o
2 CReqHeader.o CRespHeader2.o CTime.o Utils.o
3 g++ -o edit main.o CDnsQuery.o CHttpClient3.o CHttpSession2.o
4 CReqHeader.o CRespHeader2.o CTime.o Utils.o
5 main.o:main.cpp CHttpClient3.h
6 g++ -c main.cpp
7 CDnsQuery.o:CDnsQuery.cpp netinc.h
8 g++ -c CDnsQuery.cpp
9 CHttpClient3.o:CHttpClient3.cpp CTime.h
10 g++ -c CHttpClient3.cpp
11 CHttpSession2.o:CHttpSession2.cpp netinc.h CDnsQuery.h CMutex.h
12 g++ -c CHttpSession2.cpp -L/usr/local/ssl/lib -lssl
13 CReqHeader.o:CReqHeader.cpp
14 g++ -c CReqHeader.cpp
15 CRespHeader2.o:CRespHeader2.cpp
16 g++ -c CRespHeader2.cpp
17 CTime.o:CTime.cpp Utils.h
18 g++ -c CTime.cpp
19 Utils.o:Utils.cpp
20 g++ -c Utils.cpp
21
22 clean:
23 rm edit main.o CDnsQuery.o CHttpClient3.o CHttpSession2.o
24 CReqHeader.o CRespHeader2.o CTime.o Utils.o
编译时出现如下错误:
CHttpSession2.o: In function `CHttpSession::Disconnect()':
CHttpSession2.cpp:(.text+0x55): undefined reference to `SSL_shutdown'
CHttpSession2.cpp:(.text+0x66): undefined reference to `SSL_free'
CHttpSession2.o: In function `CHttpSession::ReadWithSSL(char*, int)':
CHttpSession2.cpp:(.text+0x170): undefined reference to `SSL_read'
CHttpSession2.o: In function `CHttpSession::NewSession()':
CHttpSession2.cpp:(.text+0x657): undefined reference to `SSL_new'
CHttpSession2.cpp:(.text+0x692): undefined reference to `SSL_set_fd'
CHttpSession2.cpp:(.text+0x6ac): undefined reference to `SSL_free'
CHttpSession2.o: In function `CHttpSession::Connect()':
CHttpSession2.cpp:(.text+0x77f): undefined reference to `SSL_connect'
CHttpSession2.o: In function `CHttpSession::WriteWithSSL(char const*, int)':
CHttpSession2.cpp:(.text+0x857): undefined reference to `SSL_write'
CHttpSession2.o: In function `CHttpSession::SSLCleanup()':
CHttpSession2.cpp:(.text+0xa9f): undefined reference to `CRYPTO_set_locking_callback'
CHttpSession2.cpp:(.text+0xafb): undefined reference to `SSL_CTX_free'
CHttpSession2.o: In function `CHttpSession::InitSSL()':
CHttpSession2.cpp:(.text+0xb25): undefined reference to `SSL_library_init'
CHttpSession2.cpp:(.text+0xb2a): undefined reference to `OPENSSL_add_all_algorithms_noconf'
CHttpSession2.cpp:(.text+0xb2f): undefined reference to `SSLv23_client_method'
CHttpSession2.cpp:(.text+0xb37): undefined reference to `SSL_CTX_new'
CHttpSession2.cpp:(.text+0xb41): undefined reference to `RAND_poll'
CHttpSession2.cpp:(.text+0xb75): undefined reference to `RAND_seed'
CHttpSession2.cpp:(.text+0xb7a): undefined reference to `RAND_status'
CHttpSession2.cpp:(.text+0xb88): undefined reference to `CRYPTO_num_locks'
CHttpSession2.cpp:(.text+0xbf7): undefined reference to `CRYPTO_set_id_callback'
CHttpSession2.cpp:(.text+0xc03): undefined reference to `CRYPTO_set_locking_callback'
collect2: ld returned 1 exit status
make: *** [edit] Error 1
忘指点 谢谢
|
在所有要用到ssl的地方加上-lssl,
另外给你改了一下Makefile文件,
$(BIN):edit
$(OBJS):main.o CDnsQuery.o CHttpClient3.o CHttpSession2.o
CReqHeader.o CRespHeader2.o CTime.o Utils.o
$(GCC):g++
.PHONY:all
all:$(BIN)
1 edit:main.o CDnsQuery.o CHttpClient3.o CHttpSession2.o
2 CReqHeader.o CRespHeader2.o CTime.o Utils.o
3 g++ -o edit main.o CDnsQuery.o CHttpClient3.o CHttpSession2.o
4 CReqHeader.o CRespHeader2.o CTime.o Utils.o
5 main.o:main.cpp CHttpClient3.h
6 g++ -c main.cpp
7 CDnsQuery.o:CDnsQuery.cpp netinc.h
8 g++ -c CDnsQuery.cpp
9 CHttpClient3.o:CHttpClient3.cpp CTime.h
10 g++ -c CHttpClient3.cpp
11 CHttpSession2.o:CHttpSession2.cpp netinc.h CDnsQuery.h CMutex.h
12 g++ -c CHttpSession2.cpp -L/usr/local/ssl/lib -lssl
13 CReqHeader.o:CReqHeader.cpp
14 g++ -c CReqHeader.cpp
15 CRespHeader2.o:CRespHeader2.cpp
16 g++ -c CRespHeader2.cpp
17 CTime.o:CTime.cpp Utils.h
18 g++ -c CTime.cpp
19 Utils.o:Utils.cpp
20 g++ -c Utils.cpp
21
22 clean:
23 rm edit main.o CDnsQuery.o CHttpClient3.o CHttpSession2.o
24 CReqHeader.o CRespHeader2.o CTime.o Utils.o
另外给你改了一下Makefile文件,
$(BIN):edit
$(OBJS):main.o CDnsQuery.o CHttpClient3.o CHttpSession2.o
CReqHeader.o CRespHeader2.o CTime.o Utils.o
$(GCC):g++
.PHONY:all
all:$(BIN)
1 edit:main.o CDnsQuery.o CHttpClient3.o CHttpSession2.o
2 CReqHeader.o CRespHeader2.o CTime.o Utils.o
3 g++ -o edit main.o CDnsQuery.o CHttpClient3.o CHttpSession2.o
4 CReqHeader.o CRespHeader2.o CTime.o Utils.o
5 main.o:main.cpp CHttpClient3.h
6 g++ -c main.cpp
7 CDnsQuery.o:CDnsQuery.cpp netinc.h
8 g++ -c CDnsQuery.cpp
9 CHttpClient3.o:CHttpClient3.cpp CTime.h
10 g++ -c CHttpClient3.cpp
11 CHttpSession2.o:CHttpSession2.cpp netinc.h CDnsQuery.h CMutex.h
12 g++ -c CHttpSession2.cpp -L/usr/local/ssl/lib -lssl
13 CReqHeader.o:CReqHeader.cpp
14 g++ -c CReqHeader.cpp
15 CRespHeader2.o:CRespHeader2.cpp
16 g++ -c CRespHeader2.cpp
17 CTime.o:CTime.cpp Utils.h
18 g++ -c CTime.cpp
19 Utils.o:Utils.cpp
20 g++ -c Utils.cpp
21
22 clean:
23 rm edit main.o CDnsQuery.o CHttpClient3.o CHttpSession2.o
24 CReqHeader.o CRespHeader2.o CTime.o Utils.o