Установлен OpenSSL, нет файла openssl.h

Я нашел ответ на вопрос на этом сайте, который я попытался реализовать с помощью здесь .

Я загрузил и установил openssl с здесь. Я выполнил каждый шаг, упомянутый в тексте установки внутри извлеченного файла.

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

Все закончилось без ошибок. Затем, когда я попытался скомпилировать код о том, как сгенерировать хеш SHA, используя пример кода из ответа на вопрос, я получил следующую ошибку:

фатальная ошибка: openssl.h: нет такого файла или каталога

Нужно ли мне делать что-то еще для создания файла заголовка openssl, как я думал, после установки openssl без каких-либо проблем он будет автоматически создан? Я впервые добавляю библиотеку в C, поэтому прошу прощения за мою наивность.

Спасибо за чтение.


person user1479836    schedule 25.06.2012    source источник
comment
Вы указали каталог для включаемых файлов с помощью параметра -I во время компиляции? (Я предполагаю, что вы работаете в Unix)   -  person Specksynder    schedule 25.06.2012


Ответы (2)


Попробуйте включить параметр -I для компиляции, указав каталог openssl при компиляции вашей примерной программы.

Это из файла INSTALL в каталоге openssl:

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

Я предлагаю вам прочитать файл INSTALL в исходном каталоге openssl, чтобы получить более подробную информацию.

person Specksynder    schedule 25.06.2012
comment
Спасибо за ответ, я действительно обнаружил, что следующая команда решила проблему: sudo apt-get install libssl-dev - person user1479836; 25.06.2012

Если у кого-то возникла такая же проблема, когда каталог openssl не отображается в его каталоге include после установки, просто используйте sudo apt-get install libssl-dev, как говорит user1479836.

person MannnnnnnnnnOhMyGawd    schedule 09.06.2021
comment
Речь идет о пользовательской компиляции OpenSSL из источников, этот ответ о том, как установить вариант разработчика OpenSSL на Ubuntu / Debian. - person Ales Teska; 10.06.2021