2012-06-25 43 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