Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4472174
  • 博文数量: 356
  • 博客积分: 10458
  • 博客等级: 上将
  • 技术积分: 4734
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-24 14:59
文章分类

全部博文(356)

文章存档

2020年(17)

2019年(9)

2018年(26)

2017年(5)

2016年(11)

2015年(20)

2014年(2)

2013年(17)

2012年(15)

2011年(4)

2010年(7)

2009年(14)

2008年(209)

分类: LINUX

2017-09-27 15:57:13

在从旧的ubuntu迁移一个调用 openssl的程序到新ubuntu服务器时出现了些问题
环境ubuntu

内核
Linux ntt-misc 4.4.0-93-generic #116-Ubuntu SMP Fri Aug 11 21:17:51 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

部分ssl代码:
ssl_method = SSLv3_server_method();
ssl_ctx = SSL_CTX_new(ssl_method);
if (ssl_ctx == NULL)
{
    // 这里可能出错退出
    ERR_print_errors_fp(stdout);
    return -1;
}

g++ -g  -DRELEASE test.cpp -I../ -lssl -lcrypto -lpthread -lcurl -o test
这种方式执行出错
140304116860600:error:140A90C4:lib(20):func(169):reason(196):ssl_lib.c:1878:
查了下原因应该是系统库中的ssl库不支持sslv3导致,看系统中用的ssl库是1.0.2g版本
所以就从ssl官方下载了1.0.2g的源码重新编译出静态库进行编译
 make
g++ -g  -DRELEASE test.cpp -I../ libssl.a libcrypto.a -lpthread -lcurl -o test
出错:
/usr/bin/ld: libcrypto.a(dso_dlfcn.o): undefined reference to symbol 'dlclose@@GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libdl.so.2: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

改成g++ -g  -DRELEASE test.cpp -I../ -ldl libssl.a libcrypto.a -lpthread -lcurl -o test
也是一样的错误

改成 g++ -g  -DRELEASE test.cpp -I../ libssl.a libcrypto.a -ldl -lpthread -lcurl -o test
成功编译,看来是-ldl的位置有要求。

作者:帅得不敢出门   程序员群:31843264
阅读(1970) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~