linux-坑爹的undefined reference to `SHA1'
来源:互联网 发布:mac safari添加收藏 编辑:程序博客网 时间:2024/06/15 04:59
一程序需要使用openssl中的SHA1方法.安装openssl后,一直报undefined reference to `SHA1'这个错误.
示例程序源码如下:
#include <iostream>#include <iomanip>#include <string>#include <openssl/sha.h>using namespace std;int main(int argc, char* argv[]){string input;unsigned char hash[20];cout << "enter your string: ";getline(cin, input);SHA1((unsigned char*)input.c_str(), input.size(), hash);cout << "the hash was: ";for(int i = 0; i < 20; ++i) {cout << hex << setw(2) << setfill('0') << (int)hash[i];}cout << endl;}网上一搜,都是安装openssl ,编译时候加上-lssl.问题我是整死弄不过。openssl版本换了多个,问题依旧.ubuntu版本从10.04也换到了11.10,问题依旧.
找同学试,他竟然用-lssl编译成功了.坑爹啊..
继续在网上看啊,终于让我看到了.不用-lssl,而用-lcrypto.最后终于编译成功啦.激动啊..特意记录下来.
总结:
如果遇到这类问题,先试试-lssl,如果不行,换用-lcrypto.我感觉这个还是与系统有关.
附:
openssl源码安装方法.
./config --prefix=/usr/local --openssldir=/usr/local/opensslmakemake install
- linux-坑爹的undefined reference to `SHA1'
- undefined reference to `SHA1'
- [Linux] undefined reference to `pthread_create'
- [linux]undefined reference to `__gxx_personality_v0'
- Linux undefined reference to `cos'
- [Linux] undefined reference to `itoa'
- [Linux] undefined reference to `itoa'
- Linux undefined reference to av_register_all
- Linux undefined reference to `cos'
- linux undefined reference to 'libiconv'
- linux中报错:undefined reference to
- [Linux] undefined reference to `itoa'
- undefined reference to `minor' undefined reference to `major'的解决方案
- ”Undefined reference to“ 的处理
- ”Undefined reference to“ 的处理
- ”Undefined reference to“ 的处理
- Undefined reference to” 的处理
- “Undefined reference to” 的处理
- Android读写文件正确实行方法介绍
- Android 漂亮的 Dialog (弹出框)
- VisualStudio 删除连续换行
- Android之菜单总结
- Struts2应用开发步骤
- linux-坑爹的undefined reference to `SHA1'
- nginx 源码学习笔记(二十)—— event 模块(一) ——初始化
- silverlight4中dataPager控件的简单使用
- 小经验
- PCRE的模式修饰符
- 如何实现Android两个模拟器之间的通信
- SQL SERVER 2008过了评估期
- .net中模块
- 堆栈的使用