2

I have found an answer to a question on this site, which I have tried to implement from here.

I downloaded and installed openssl from here. I performed each step mentioned within the install text inside the extracted file.

$ ./config $ make $ make test $ make install

These all finished without error. Then when I tried to compile the code on how to generate an SHA hash using the example code from the answered question, I am given the following error:

fatal error: openssl.h: No such file or directory

Do I have to do something more to create the openssl header file, as I thought after installing openssl without any problems it would be automatically created? This is the first time I am adding a library to C, so please excuse any naiveties on my part.

Thanks for reading.

Community
  • 1
  • 1
user1479836
  • 93
  • 1
  • 2
  • 5
  • Have you specified the directory for include files using the -I option during compilation?(I assume you are on Unix) – Specksynder Jun 25 '12 at 11:46

2 Answers2

1

Try including the -I option for compilation specifying the openssl directory when compiling your example program.

This is from the INSTALL file in the openssl directory:

  *  WRITING applications

     To write an application that is able to handle both the new
     and the old directory layout, so that it can still be compiled
     with library versions up to OpenSSL 0.9.2b without bothering
     the user, you can proceed as follows:

     -  Always use the new filename of OpenSSL header files,
        e.g. #include <openssl/ssl.h>.

     -  Create a directory "incl" that contains only a symbolic
        link named "openssl", which points to the "include" directory
        of OpenSSL.
        For example, your application's Makefile might contain the
        following rule, if OPENSSLDIR is a pathname (absolute or
        relative) of the directory where OpenSSL resides:

        incl/openssl:
                -mkdir incl
                cd $(OPENSSLDIR) # Check whether the directory really exists
                -ln -s `cd $(OPENSSLDIR); pwd`/include incl/openssl

        You will have to add "incl/openssl" to the dependencies
        of those C files that include some OpenSSL header file.

     -  Add "-Iincl" to your CFLAGS.

     With these additions, the OpenSSL header files will be available
     under both name variants if an old library version is used:
     Your application can reach them under names like <openssl/foo.h>,
     while the header files still are able to #include each other
     with names of the form <foo.h>.

I suggest you read the INSTALL file in the openssl source directory to get more details.

Specksynder
  • 813
  • 9
  • 20
  • Thanks for responding, I have actually found that the following command solved the problem: sudo apt-get install libssl-dev – user1479836 Jun 25 '12 at 12:09
0

If anyone is having this same issue where the openssl directory isn't appearing in their include directory after installation, just use sudo apt-get install libssl-dev like user1479836 says.

  • 1
    The question is about custom compilation of OpenSSL from sources, this answer is about how to install "developer" variant of OpenSSL on Ubuntu / Debian. – Ales Teska Jun 09 '21 at 23:33