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?
If you're linking with
-lfoo
then the library is likelylibfoo.so
. The library itself is probably part of thelibfoo
package, and the headers are in thelibfoo-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 thatapt-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 typingsudo apt-get
and then hitting tab.sudo apt-get install libcurl4-openssl-dev
apt-get install libssl-dev
You want to install the development package, which is libssl-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.
Another way to install openssl library from source code on Ubuntu, follows steps below, here
WORKDIR
is your working directory: