ssl链接问题

skyspark 2008-06-04 11:50:04
自己刚学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

忘指点 谢谢
...全文
390 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
skyspark 2008-06-04
  • 打赏
  • 举报
回复
谢谢啊 这样简单多了
linqzly 2008-06-04
  • 打赏
  • 举报
回复
不好意思楼主,按错键了
$(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)

$(BIN):$(OBJS)
$(GCC) -o $@ $^ -lssl
.PHONY:clean
clean:
rm -f $(BIN) $(OBJS)
linqzly 2008-06-04
  • 打赏
  • 举报
回复
在所有要用到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
skyspark 2008-06-04
  • 打赏
  • 举报
回复
来个人领分把 我自己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 -lssl

23,124

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧