我在这个网站上找到了一个问题的答案,我试图从here实施。
我从here下载并安装了openssl。我执行了解压缩文件中安装文本中提到的每个步骤。
$ ./config $ make $ make test $ make install
这些都完成没有错误。然后,当我尝试使用回答问题中的示例代码编译有关如何生成SHA哈希的代码时,我收到以下错误:
致命错误:openssl.h:没有这样的文件或目录
我是否必须做更多的事情才能创建openssl头文件,因为我认为在安装openssl后没有任何问题会自动创建?这是我第一次向C添加一个库,所以请原谅我的任何天真。
谢谢阅读。
在编译示例程序时,请尝试包含-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文件以获取更多细节。