报错:undefined reference to `OPENSSL_init_ssl'

报错:

root@ubuntu:/mnt/hgfs/Ubuntu12.04-share/test/2_file/https# gcc -o test test.c  -lcrypto
/tmp/ccmg6lsM.o: In function `sslConnect':
test.c:(.text+0x134): undefined reference to `OPENSSL_init_ssl'
test.c:(.text+0x143): undefined reference to `OPENSSL_init_ssl'
test.c:(.text+0x157): undefined reference to `TLS_client_method'
test.c:(.text+0x15f): undefined reference to `SSL_CTX_new'
test.c:(.text+0x193): undefined reference to `SSL_new'
test.c:(.text+0x1cf): undefined reference to `SSL_set_fd'
test.c:(.text+0x1f2): undefined reference to `SSL_connect'
/tmp/ccmg6lsM.o: In function `sslDisconnect':
test.c:(.text+0x258): undefined reference to `SSL_shutdown'
test.c:(.text+0x268): undefined reference to `SSL_free'
test.c:(.text+0x285): undefined reference to `SSL_CTX_free'
/tmp/ccmg6lsM.o: In function `sslRead':
test.c:(.text+0x37b): undefined reference to `SSL_read'
/tmp/ccmg6lsM.o: In function `sslWrite':
test.c:(.text+0x430): undefined reference to `SSL_write'
collect2: error: ld returned 1 exit status
root@ubuntu:/mnt/hgfs/Ubuntu12.04-share/test/2_file/https#

解决方法: 加上参数 “-lssl

root@ubuntu:/mnt/hgfs/Ubuntu12.04-share/test/2_file/https# gcc -o test test.c  -lcrypto -lssl
root@ubuntu:/mnt/hgfs/Ubuntu12.04-share/test/2_file/https# ls
test  test.c
root@ubuntu:/mnt/hgfs/Ubuntu12.04-share/test/2_file/https# 
  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
编译报错如下:CMakeFiles/t3_node.dir/src/main.cpp.o: In function `boost::asio::ssl::detail::openssl_init_base::do_init::~do_init()': main.cpp:(.text._ZN5boost4asio3ssl6detail17openssl_init_base7do_initD2Ev[_ZN5boost4asio3ssl6detail17openssl_init_base7do_initD5Ev]+0x12): undefined reference to `CONF_modules_unload' CMakeFiles/t3_node.dir/src/main.cpp.o: In function `boost::asio::error::detail::ssl_category::message[abi:cxx11](int) const': main.cpp:(.text._ZNK5boost4asio5error6detail12ssl_category7messageB5cxx11Ei[_ZNK5boost4asio5error6detail12ssl_category7messageB5cxx11Ei]+0x2c): undefined reference to `ERR_reason_error_string' main.cpp:(.text._ZNK5boost4asio5error6detail12ssl_category7messageB5cxx11Ei[_ZNK5boost4asio5error6detail12ssl_category7messageB5cxx11Ei]+0x48): undefined reference to `ERR_lib_error_string' main.cpp:(.text._ZNK5boost4asio5error6detail12ssl_category7messageB5cxx11Ei[_ZNK5boost4asio5error6detail12ssl_category7messageB5cxx11Ei]+0x59): undefined reference to `ERR_func_error_string' collect2: error: ld returned 1 exit status t3/CMakeFiles/t3_node.dir/build.make:318: recipe for target '/smartview/devel/lib/t3/t3_node' failed make[2]: *** [/smartview/devel/lib/t3/t3_node] Error 1 CMakeFiles/Makefile2:3555: recipe for target 't3/CMakeFiles/t3_node.dir/all' failed make[1]: *** [t3/CMakeFiles/t3_node.dir/all] Error 2 make[1]: *** Waiting for unfinished jobs.... [ 96%] Built target play_node [100%] Built target smartview_handler Makefile:145: recipe for target 'all' failed make: *** [all] Error 2 Invoking "make -j20 -l20" failed
最新发布
06-09

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值