我试图在使用OpenSSL 1.0.0的Ubuntu 10.04 LTS上构建一些代码。当我运行make时,它使用“-lssl”选项调用g++。资料来源包括:
#include <openssl/bio.h>
#include <openssl/buffer.h>
#include <openssl/des.h>
#include <openssl/evp.h>
#include <openssl/pem.h>
#include <openssl/rsa.h>
我跑:
$ sudo apt-get install openssl
Reading package lists... Done
Building dependency tree
Reading state information... Done
openssl is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
但是我猜openssl包不包括这个库。我在make时得到这些错误:
foo.cpp:21:25: error: openssl/bio.h: No such file or directory
foo.cpp:22:28: error: openssl/buffer.h: No such file or directory
foo.cpp:23:25: error: openssl/des.h: No such file or directory
foo.cpp:24:25: error: openssl/evp.h: No such file or directory
foo.cpp:25:25: error: openssl/pem.h: No such file or directory
foo.cpp:26:25: error: openssl/rsa.h: No such file or directory
如何在Ubuntu 10.04 LTS上安装OpenSSL c++库?
我为-l选项做了一个man g++和(在“链接选项”下),它声明:“链接器为库搜索一个标准目录列表…”和“搜索的目录包括几个标准系统目录…”这些标准系统目录是什么?
我是怎么知道的
我自己(除了问这个
问题)?我能不能告诉你
Apt-get列出所有包,以及grep . get
ssl ?还是我需要知道
“lib*-dev”命名规范?
如果你用-lfoo链接,那么这个库很可能是libfoo.so。库本身可能是libfoo包的一部分,并且正如您所发现的,头文件位于libfoo-dev包中。
有些人使用GUI“synaptic”应用程序(sudo synaptic)来(定位和)安装包,但我更喜欢使用命令行。更容易从命令行找到正确的包的一个原因是apt-get支持bash补全。
尝试输入sudo apt-get install libssl,然后按tab键查看匹配的包名列表(当您需要选择具有多个版本或其他可用变体的包的正确版本时,这可以提供帮助)。
Bash补全实际上非常有用…例如,您还可以通过键入sudo apt-get然后按tab键来获得apt-get支持的命令列表。
我在这里找到了详细的解决方案:在Linux上手动安装OpenSSL
从博客文章中…
Steps to download, compile, and install are as follows (I'm installing version 1.0.1g below; please replace "1.0.1g" with your version number):
Step – 1 : Downloading OpenSSL:
Run the command as below :
$ wget http://www.openssl.org/source/openssl-1.0.1g.tar.gz
Also, download the MD5 hash to verify the integrity of the downloaded file for just varifacation purpose. In the same folder where you have downloaded the OpenSSL file from the website :
$ wget http://www.openssl.org/source/openssl-1.0.1g.tar.gz.md5
$ md5sum openssl-1.0.1g.tar.gz
$ cat openssl-1.0.1g.tar.gz.md5
Step – 2 : Extract files from the downloaded package:
$ tar -xvzf openssl-1.0.1g.tar.gz
Now, enter the directory where the package is extracted like here is openssl-1.0.1g
$ cd openssl-1.0.1g
Step – 3 : Configuration OpenSSL
Run below command with optional condition to set prefix and directory where you want to copy files and folder.
$ ./config --prefix=/usr/local/openssl --openssldir=/usr/local/openssl
You can replace “/usr/local/openssl” with the directory path where you want to copy the files and folders. But make sure while doing this steps check for any error message on terminal.
Step – 4 : Compiling OpenSSL
To compile openssl you will need to run 2 command : make, make install as below :
$ make
Note: check for any error message for verification purpose.
Step -5 : Installing OpenSSL:
$ sudo make install
Or without sudo,
$ make install
That’s it. OpenSSL has been successfully installed. You can run the version command to see if it worked or not as below :
$ /usr/local/openssl/bin/openssl version
OpenSSL 1.0.1g 7 Apr 2014
一般来说,当你在Debian或Ubuntu上丢失了一个开发文件(或任何其他文件)时,使用apt-file来找出哪个包提供了该文件:
~ apt-file search openssl/bio.h
android-libboringssl-dev: /usr/include/android/openssl/bio.h
libssl-dev: /usr/include/openssl/bio.h
libwolfssl-dev: /usr/include/cyassl/openssl/bio.h
libwolfssl-dev: /usr/include/wolfssl/openssl/bio.h
快速浏览命令返回的每个包,使用apt show将告诉您在这些包中寻找哪个包:
~ apt show libssl-dev
Package: libssl-dev
Version: 1.1.1d-2
Priority: optional
Section: libdevel
Source: openssl
Maintainer: Debian OpenSSL Team <pkg-openssl-devel@lists.alioth.debian.org>
Installed-Size: 8,095 kB
Depends: libssl1.1 (= 1.1.1d-2)
Suggests: libssl-doc
Conflicts: libssl1.0-dev
Homepage: https://www.openssl.org/
Tag: devel::lang:c, devel::library, implemented-in::TODO, implemented-in::c,
protocol::ssl, role::devel-lib, security::cryptography
Download-Size: 1,797 kB
APT-Sources: http://ftp.fr.debian.org/debian unstable/main amd64 Packages
Description: Secure Sockets Layer toolkit - development files
This package is part of the OpenSSL project's implementation of the SSL
and TLS cryptographic protocols for secure communication over the
Internet.
.
It contains development libraries, header files, and manpages for libssl
and libcrypto.
N: There is 1 additional record. Please use the '-a' switch to see it
所有这些答案都是非常过时的,来自于软件包仍在开发的时候。你现在可以使用下面列出的"normal"命令:
sudo apt install openssl
编辑:OP的问题措辞很糟糕…毕竟,OpenSSL本身就是一个库,所以我在回答他的问题之前看得太快了。上面的命令安装“普通”OpenSSL。
在他的问题的末尾,他提到了make失败,这表明他正在手动编译包。是的,即使您下载了TAR球,它也将包括所有的openssl和libssl文件,然后您可以从中进行制作。
OP真正需要的是OpenSSL开发库,在这种情况下,你可以先使用上面的命令安装OpenSSL,然后再运行这个:
sudo apt install libssl-dev
更多信息:https://linuxtect.com/how-to-install-openssl-libraries-on-ubuntu-debian-mint/