How to use OpenSSL with GCC?(如何在 GCC 中使用 OpenSSL?)
问题描述
我正在尝试在 gcc 程序中使用 openssl 但它不起作用.
I'm trying to use openssl in a gcc program but it isn't working.
g++ server.cpp /usr/lib/libssl.a -o server
给出错误消息,与 -l 选项一样.我必须在命令行上输入什么才能与 openssl 链接?文件 /usr/lib/libssl.a 存在,但我仍然收到链接器错误no such function MD5() exists.
gives an error message, as does anything with the -l option. What must I type on the command line to link with openssl? The file /usr/lib/libssl.a exists, but nevertheless I still get the linker error no such function MD5() exists.
推荐答案
如果不知道所看到的确切错误,就很难提供准确的解决方案.这是我最好的尝试.
Without knowing the exact errors you are seeing, it is difficult to provide an exact solution. Here is my best attempt.
从您提供的信息来看,链接器似乎失败了,因为它在 libssl.a 中找不到对 md5 函数的引用.我相信这个函数实际上在 libcrypto 中,所以你可能也需要指定这个库.
From the information you provided, it sounds as though the linker is failing because it cannot find a reference to the md5 function in libssl.a. I believe this function is actually in libcrypto so you may need to specify this library as well.
g++ server.cpp -L/usr/lib -lssl -lcrypto -o server
这篇关于如何在 GCC 中使用 OpenSSL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 GCC 中使用 OpenSSL?
基础教程推荐
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- CString 到 char* 2021-01-01
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- 初始化列表*参数*评估顺序 2021-01-01
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
