openssl编程编译错误undefined reference to `SSL_get1_peer_certificate‘解决方法
Posted 今天也要努力搬砖
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了openssl编程编译错误undefined reference to `SSL_get1_peer_certificate‘解决方法相关的知识,希望对你有一定的参考价值。
问题:
[100%] Linking C executable example_ssl_serv
CMakeFiles/example_ssl_serv.dir/example_ssl_serv.c.o: In function `main':
example_ssl_serv.c:(.text+0x49e): undefined reference to `SSL_get1_peer_certificate'
collect2: error: ld returned 1 exit status
CMakeFiles/example_ssl_serv.dir/build.make:94: recipe for target 'example_ssl_serv' failed
make[2]: *** [example_ssl_serv] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/example_ssl_serv.dir/all' failed
make[1]: *** [CMakeFiles/example_ssl_serv.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
root@cd2e1925ffbe:/work/CyberSecurityCode/sslservexample# ^C
原因:
SSL_get1_peer_certificate源码里调用的是SSL_get_peer_certificate,而报错的是SSL_get1_peer_certificate这个函数,所以问题应该出现在库里面而不是源码里面。具体原因不太确定,感觉和某个编译选项有关
解决方法 :
执行以下命令重新编译安装
进入openssl目录
cd /work/download/openssl-1.1.1o/
设置confgi
./config --prefix=/usr/local --openssldir=/etc/ssl --libdir=lib enable-ssl3 enable-ssl3-method enable-weak-ssl-ciphers -DOPENSSL_NO_GOST zlib shared
make和make install
make
make install
使用新版Openssl
ln -s /usr/local/bin/openssl /usr/bin/openssl
ln -s /usr/local/include/openssl/ /usr/include/openssl
跟新动态链接库
echo "/usr/local/lib/" >> /etc/ld.so.conf
ldconfig
以上是关于openssl编程编译错误undefined reference to `SSL_get1_peer_certificate‘解决方法的主要内容,如果未能解决你的问题,请参考以下文章
编译openssl失败(SLES11.3), undefined reference to `OPENSSL_cpuid_setup'
Bitcoin 编译0.19版本时“undefined reference to `OPENSSL_init_crypto‘”
Android编译错误——undefined reference to
Linux下运行《UNIX环境高级编程》undefined reference to `err_quit 编译出错的处理方法