如何在 Ubuntu 上安装 OpenSSL 库?

发布于 2024-09-05 17:11:32 字数 1210 浏览 4 评论 0 原文

我正在尝试在使用 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

How do I install the OpenSSL C++ library on Ubuntu 10.04 LTS?

我做了一个 man g++ 和(在“链接选项”下)它的 -l 选项指出:“链接器搜索库的标准目录列表...”和“搜索的目录包括几个标准系统目录...”那些标准系统目录是什么?

I'm trying to build some code on Ubuntu 10.04 LTS that uses OpenSSL 1.0.0. When I run make, it invokes g++ with the "-lssl" option. The source includes:

#include <openssl/bio.h>
#include <openssl/buffer.h>
#include <openssl/des.h>
#include <openssl/evp.h>
#include <openssl/pem.h>
#include <openssl/rsa.h>

I ran:

$ 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.

But I guess the openssl package doesn't include the library. I get these errors on 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

How do I install the OpenSSL C++ library on Ubuntu 10.04 LTS?

I did a man g++ and (under "Options for Linking") for the -l option it states: " The linker searches a standard list of directories for the library..." and "The directories searched include several standard system directories..." What are those standard system directories?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(10

昵称有卵用 2024-09-12 17:11:32

您要安装开发包,即 libssl-dev:

sudo apt-get install libssl-dev

You want to install the development package, which is libssl-dev:

sudo apt-get install libssl-dev
櫻之舞 2024-09-12 17:11:32

跑步:

apt-get install libssl-dev

Run:

apt-get install libssl-dev
久光 2024-09-12 17:11:32

所有这些答案都非常过时,并且从包仍在开发的时候开始。您现在可以使用下面列出的“正常”命令:

sudo apt install openssl

编辑:OP 的问题措辞很差...毕竟,OpenSSL 本身就是一个库,所以我在回答之前太快地阅读了他的问题。上面的命令安装“普通”OpenSSL。

在问题的底部,他提到 make 失败,这表明他正在手动编译该包。是的,即使您下载 TAR 球,它也会包含所有 openssllibssl 文件,然后您可以使用它们来make

OP真正需要的是OpenSSL开发库,在这种情况下,您可以首先使用上述命令安装OpenSSL,然后运行此命令:

sudo apt install libssl-dev

更多信息:https://linuxtect.com/how-to-install-openssl-libraries-on-ubuntu -debian-mint/

All of these answers are very outdated and from when the package was still being developed. You can now just use the "normal" command listed below:

sudo apt install openssl

Edit: OP's question is poorly worded... after all, OpenSSL is a library itself, so I read his question too quickly before answering. The command above installs "normal" OpenSSL.

Toward the bottom of his question he mentions that make fails, suggesting he is compiling the package manually. And yes, even if you download the TAR ball, it will include all of the openssl and libssl files, which you can then make from.

What OP is really asking for is the OpenSSL Development Library, in which case you can first install OpenSSL using the above command, and then run this afterwards:

sudo apt install libssl-dev

More info: https://linuxtect.com/how-to-install-openssl-libraries-on-ubuntu-debian-mint/

七禾 2024-09-12 17:11:32

我在这里找到了详细的解决方案:Install OpenSSL Manually On Linux

摘自博客文章...:

下载、编译、安装步骤如下(我安装的是下面的1.0.1g版本;请将“1.0.1g”替换为您的版本号):

第 1 步:下载 OpenSSL:

运行命令如下:

$ wget http://www.openssl.org/source/openssl-1.0.1g.tar.gz

此外,还可以下载 MD5 哈希值来验证下载文件的完整性,以用于变异目的。在您从网站下载 OpenSSL 文件的同一文件夹中:

$ 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

步骤 - 2:从下载的包中提取文件:

$ tar -xvzf openssl-1.0.1g.tar.gz

现在,进入解压包的目录,例如 openssl-1.0.1g

$ cd openssl-1.0.1g

第 3 步:配置 OpenSSL

运行以下命令并附加可选条件来设置要复制文件和文件夹的前缀和目录。

$ ./config --prefix=/usr/local/openssl --openssldir=/usr/local/openssl

您可以将“/usr/local/openssl”替换为要复制文件和文件夹的目录路径。但请确保在执行此步骤时检查终端上是否有任何错误消息。

第 4 步:编译 OpenSSL

要编译 openssl,您需要运行 2 个命令:make、make install,如下所示:

$ make

注意:检查是否有任何错误消息以进行验证。

步骤-5:安装 OpenSSL:

$ sudo make install

或者不使用 sudo,

$ make install

就是这样。 OpenSSL 已成功安装。您可以运行 version 命令来查看它是否有效,如下所示:

$ /usr/local/openssl/bin/openssl 版本

OpenSSL 1.0.1g 2014 年 4 月 7 日

I found a detailed solution here: Install OpenSSL Manually On Linux

From the blog post...:

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

莳間冲淡了誓言ζ 2024-09-12 17:11:32

我怎么能想到这一点
我自己(除了问这个
问题在这里)?我能以某种方式告诉
apt-get 列出所有软件包,以及 grep
对于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 然后点击 支持的命令列表>选项卡

How could I have figured that out for
myself (other than asking this
question here)? Can I somehow tell
apt-get to list all packages, and grep
for ssl? Or do I need to know the
"lib*-dev" naming convention?

If you're linking with -lfoo then the library is likely libfoo.so. The library itself is probably part of the libfoo package, and the headers are in the libfoo-dev package as you've discovered.

Some people use the GUI "synaptic" app (sudo synaptic) to (locate and) install packages, but I prefer to use the command line. One thing that makes it easier to find the right package from the command line is the fact that apt-get supports bash completion.

Try typing sudo apt-get install libssl and then hit tab to see a list of matching package names (which can help when you need to select the correct version of a package that has multiple versions or other variations available).

Bash completion is actually very useful... for example, you can also get a list of commands that apt-get supports by typing sudo apt-get and then hitting tab.

海未深 2024-09-12 17:11:32

在 Ubuntu 上从源代码安装 openssl 库的另一种方法,请按照以下步骤操作,这里 WORKDIR 是您的工作目录:

sudo apt-get install pkg-config
cd WORKDIR
git clone https://github.com/openssl/openssl.git
cd openssl
./config
make
sudo make install
# Open file /etc/ld.so.conf, add a new line: "/usr/local/lib" at EOF
sudo ldconfig

Another way to install openssl library from source code on Ubuntu, follows steps below, here WORKDIR is your working directory:

sudo apt-get install pkg-config
cd WORKDIR
git clone https://github.com/openssl/openssl.git
cd openssl
./config
make
sudo make install
# Open file /etc/ld.so.conf, add a new line: "/usr/local/lib" at EOF
sudo ldconfig
谜泪 2024-09-12 17:11:32

作为一般规则,当在 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 <[email protected]>
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

As a general rule, when on Debian or Ubuntu and you're missing a development file (or any other file for that matter), use apt-file to figure out which package provides that 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

A quick glance at each of the packages that are returned by the command, using apt show will tell you which among the packages is the one you're looking for:

~ apt show libssl-dev
Package: libssl-dev
Version: 1.1.1d-2
Priority: optional
Section: libdevel
Source: openssl
Maintainer: Debian OpenSSL Team <[email protected]>
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
淤浪 2024-09-12 17:11:32

您需要 openssl-devel 包。
至少我认为它是 Ubuntu 上的 -devel 。可能是-dev。这是两者之一。

You want the openssl-devel package.
At least I think it's -devel on Ubuntu. Might be -dev. It's one of the two.

不醒的梦 2024-09-12 17:11:32
  1. 前往官网下载您需要的版本源码

  2. 然后解压更新包并执行以下命令

    ./config --prefix=/usr/local/ssl --openssldir=/usr/local/ssl -Wl,-rpath,/usr/local/ssl/lib 共享
    

因为默认只生成静态库,所以如果想要动态库,就添加"shared"选项

  1. make &&进行安装
  1. Go to the official website and download the source code for the version you need

  2. Then unzip the update package and execute the following command

    ./config --prefix=/usr/local/ssl --openssldir=/usr/local/ssl  -Wl,-rpath,/usr/local/ssl/lib shared
    

Because the default is to generate only static libraries, if you want dynamic libraries, add the "shared" option

  1. make && make install
寄风 2024-09-12 17:11:32

sudo apt-get install libcurl4-openssl-dev

sudo apt-get install libcurl4-openssl-dev

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文