2012-06-25 33 views
1

我找到了本网站的一个问题的答案,我试图从here实现。安装了OpenSSL,没有openssl.h文件

我从here下载并安装了openssl。我执行提取文件中的安装文本中提到的每个步骤。

$ ./config中 $使 $使测试 $ make install的

这些都完成后没有错误。然后,当我试图编译如何使用从回答问题的示例代码生成SHA哈希码的代码,我给出以下错误:

致命错误:openssl.h:没有这样的文件或目录

我是否需要做更多的事情来创建openssl头文件,正如我在安装openssl之后所想的那样,没有任何问题它会自动创建?这是我第一次为C添加一个库,所以请原谅我的任何天真。

感谢您的阅读。

+0

您是否在编译过程中使用-I选项指定了包含文件的目录?(我假设您在Unix上) – Specksynder

回答

0

在编译示例程序时,试着包括用于编译的-I选项来指定openssl目录。

这是在OpenSSL目录的INSTALL文件:

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

我建议你阅读,在OpenSSL源目录的INSTALL文件以获得更多的细节。

+0

感谢您的回复,我已经发现以下命令解决了这个问题:sudo apt-get install libssl -dev – user1479836