如何在Ubuntu上安装OpenSSL库?

时间:2022-08-13 07:16:59

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:

我正在尝试在Ubuntu 10.04 LTS上构建一些使用OpenSSL 1.0.0的代码。当我运行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>

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:

但是我猜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?

如何在Ubuntu 10.04 LTS上安装OpenSSL c++库?

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?

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

6 个解决方案

#1


345  

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

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

sudo apt-get install libssl-dev

#2


22  

apt-get install libssl-dev

apt-get安装libssl-dev

#3


11  

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?

我怎么能自己算出来(除了问这个问题)?我可以告诉apt-get列出所有包,以及用于ssl的grep吗?还是需要知道“lib*-dev”命名约定?

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.

如果要链接-lfoo,那么库很可能是libfooso。库本身可能是libfoo包的一部分,正如您所发现的,头文件在libfoo-dev包中。

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.

有些人使用gui“synaptic”应用(sudo synaptic)来(定位和)安装包,但我更喜欢使用命令行。使从命令行找到正确的包更容易的一件事是apt-get支持bash完成。

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

尝试输入sudo apt-get install libssl,然后单击“tab”查看匹配的包名称列表(当您需要选择具有多个版本或其他可用版本的包的正确版本时,这将有所帮助)。

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

Bash完成实际上非常有用……例如,您还可以通过输入sudo apt-get然后点击“tab”获得“apt-get”支持的命令列表。

#4


4  

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

您需要openssl-devel包。至少我认为它是-devel的Ubuntu。可能是- dev。它是其中之一。

#5


3  

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

从Ubuntu的源代码安装openssl库的另一种方法如下,WORKDIR是您的工作目录:

  1. sudo apt-get install pkg-config
  2. sudo apt-get安装pkg-config
  3. cd WORKDIR
  4. cd WORKDIR
  5. git clone https://github.com/openssl/openssl.git
  6. git克隆https://github.com/openssl/openssl.git
  7. cd openssl
  8. cd openssl
  9. ./config
  10. 。/配置
  11. make
  12. 使
  13. sudo make install
  14. sudo make install
  15. Open file /etc/ld.so.conf, add a new line: "/usr/local/lib" at EOF
  16. 打开文件/etc/ld.so.conf,在EOF增加一行:“/usr/local/lib”
  17. sudo ldconfig
  18. sudo ldconfig

#6


1  

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

我在这里找到了一个详细的解决方案:在Linux上手动安装OpenSSL。

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):

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

Step – 1 : Downloading OpenSSL:

步骤1:下载OpenSSL:

Run the command as below :

运行以下命令:

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

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 :

另外,下载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

$ wget http://www.openssl.org/source/openssl-1.0.1g. gz.md5 $ md5和openssl-1.0.1g.tar。广州猫openssl-1.0.1g.tar.gz.md5美元

Step – 2 : Extract files from the downloaded package:

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

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

美元焦油-xvzf openssl-1.0.1g.tar.gz

Now, enter the directory where the package is extracted like here is openssl-1.0.1g

现在,输入包被提取的目录,如下所示:openssl-1.0.1g

$ cd openssl-1.0.1g

$ cd openssl-1.0.1g

Step – 3 : Configuration OpenSSL

步骤3:配置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

美元。/配置前缀= / usr /地方/ openssl -openssldir = / usr /地方/ 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.

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

Step – 4 : Compiling OpenSSL

步骤4:编译OpenSSL

To compile openssl you will need to run 2 command : make, make install as below :

要编译openssl,您需要运行2命令:make,让安装如下:

$ make

让美元

Note: check for any error message for verification purpose.

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

Step -5 : Installing OpenSSL:

步骤5:安装OpenSSL:

$ sudo make install

$ sudo make install

Or without sudo,

或没有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 :

就是这样。OpenSSL已经成功安装。您可以运行版本命令来查看它是否工作如下:

$ /usr/local/openssl/bin/openssl version

美元/usr/local/openssl/bin/openssl版本

OpenSSL 1.0.1g 7 Apr 2014

2014年4月7日

#1


345  

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

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

sudo apt-get install libssl-dev

#2


22  

apt-get install libssl-dev

apt-get安装libssl-dev

#3


11  

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?

我怎么能自己算出来(除了问这个问题)?我可以告诉apt-get列出所有包,以及用于ssl的grep吗?还是需要知道“lib*-dev”命名约定?

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.

如果要链接-lfoo,那么库很可能是libfooso。库本身可能是libfoo包的一部分,正如您所发现的,头文件在libfoo-dev包中。

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.

有些人使用gui“synaptic”应用(sudo synaptic)来(定位和)安装包,但我更喜欢使用命令行。使从命令行找到正确的包更容易的一件事是apt-get支持bash完成。

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

尝试输入sudo apt-get install libssl,然后单击“tab”查看匹配的包名称列表(当您需要选择具有多个版本或其他可用版本的包的正确版本时,这将有所帮助)。

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

Bash完成实际上非常有用……例如,您还可以通过输入sudo apt-get然后点击“tab”获得“apt-get”支持的命令列表。

#4


4  

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

您需要openssl-devel包。至少我认为它是-devel的Ubuntu。可能是- dev。它是其中之一。

#5


3  

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

从Ubuntu的源代码安装openssl库的另一种方法如下,WORKDIR是您的工作目录:

  1. sudo apt-get install pkg-config
  2. sudo apt-get安装pkg-config
  3. cd WORKDIR
  4. cd WORKDIR
  5. git clone https://github.com/openssl/openssl.git
  6. git克隆https://github.com/openssl/openssl.git
  7. cd openssl
  8. cd openssl
  9. ./config
  10. 。/配置
  11. make
  12. 使
  13. sudo make install
  14. sudo make install
  15. Open file /etc/ld.so.conf, add a new line: "/usr/local/lib" at EOF
  16. 打开文件/etc/ld.so.conf,在EOF增加一行:“/usr/local/lib”
  17. sudo ldconfig
  18. sudo ldconfig

#6


1  

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

我在这里找到了一个详细的解决方案:在Linux上手动安装OpenSSL。

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):

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

Step – 1 : Downloading OpenSSL:

步骤1:下载OpenSSL:

Run the command as below :

运行以下命令:

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

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 :

另外,下载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

$ wget http://www.openssl.org/source/openssl-1.0.1g. gz.md5 $ md5和openssl-1.0.1g.tar。广州猫openssl-1.0.1g.tar.gz.md5美元

Step – 2 : Extract files from the downloaded package:

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

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

美元焦油-xvzf openssl-1.0.1g.tar.gz

Now, enter the directory where the package is extracted like here is openssl-1.0.1g

现在,输入包被提取的目录,如下所示:openssl-1.0.1g

$ cd openssl-1.0.1g

$ cd openssl-1.0.1g

Step – 3 : Configuration OpenSSL

步骤3:配置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

美元。/配置前缀= / usr /地方/ openssl -openssldir = / usr /地方/ 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.

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

Step – 4 : Compiling OpenSSL

步骤4:编译OpenSSL

To compile openssl you will need to run 2 command : make, make install as below :

要编译openssl,您需要运行2命令:make,让安装如下:

$ make

让美元

Note: check for any error message for verification purpose.

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

Step -5 : Installing OpenSSL:

步骤5:安装OpenSSL:

$ sudo make install

$ sudo make install

Or without sudo,

或没有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 :

就是这样。OpenSSL已经成功安装。您可以运行版本命令来查看它是否工作如下:

$ /usr/local/openssl/bin/openssl version

美元/usr/local/openssl/bin/openssl版本

OpenSSL 1.0.1g 7 Apr 2014

2014年4月7日