如何在GCC中使用OpenSSL? [英] How to use OpenSSL in GCC?

查看:146
本文介绍了如何在GCC中使用OpenSSL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在gcc程序中使用openssl,但它不起作用。

  g ++ server.cpp /usr/lib/libssl.a -o服务器

会给出一个错误消息,就像 -l <​​/ code>选项一样。我必须在命令行上键入与openssl链接的内容?文件 /usr/lib/libssl.a 存在,但我仍然得到链接器错误没有这样的函数MD5()exists

解决方案

在不知道确切的错误的情况下,很难提供确切的解决方案。这是我最好的尝试。

根据您提供的信息,听起来好像链接程序失败,因为它无法在libssl.a中找到对md5函数的引用。我相信这个函数实际上是在libcrypto中,所以你可能需要指定这个库。



g ++ server.cpp -L / usr / lib -lssl -lcrypto -o服务器


I'm trying to use openssl in a gcc program but it isn't working.

g++ server.cpp /usr/lib/libssl.a -o server

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.

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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆