Openssl编译错误在cryptlib.c中包含的文件中:117:cryptlib.h:62:20:错误:stdlib.h:没有这样的文件或目录

时间:2012-10-26 13:40:28

标签: ios openssl

我尝试使用此http://x2on.de/2010/12/16/tutorial-script-for-building-openssl-for-ios-iphoneipad/编译openssl库但得到了

In file included from cryptlib.c:117:
cryptlib.h:62:20: error: stdlib.h: No such file or directory
cryptlib.h:63:20: error: string.h: No such file or directory
In file included from cryptlib.h:65,
                 from cryptlib.c:117:
../e_os.h:444:30: error: unistd.h: No such file or directory
../e_os.h:449:29: error: sys/types.h: No such file or directory
In file included from cryptlib.h:72,
                 from cryptlib.c:117:
../include/openssl/crypto.h:125:19: error: stdio.h: No such file or directory
In file included from cryptlib.h:72,
                 from cryptlib.c:117:
../include/openssl/crypto.h:175: error: expected specifier-qualifier-list before ‘size_t’
../include/openssl/crypto.h:465: warning: parameter names (without types) in function declaration
../include/openssl/crypto.h:465: error: expected declaration specifiers or ‘...’ before ‘size_t’
../include/openssl/crypto.h:466: warning: parameter names (without types) in function declaration
../include/openssl/crypto.h:467: error: expected ‘)’ before ‘const’
../include/openssl/crypto.h:468: error: expected ‘;’, ‘,’ or ‘)’ before ‘void’
../include/openssl/crypto.h:470: error: expected ‘)’ before ‘const’
../include/openssl/crypto.h:471: error: expected ‘;’, ‘,’ or ‘)’ before ‘void’
../include/openssl/crypto.h:477: warning: parameter names (without types) in function declaration
../include/openssl/crypto.h:477: error: expected declaration specifiers or ‘...’ before ‘size_t’
../include/openssl/crypto.h:478: warning: parameter names (without types) in function declaration
../include/openssl/crypto.h:479: error: expected ‘)’ before ‘const’
../include/openssl/crypto.h:480: error: expected ‘;’, ‘,’ or ‘)’ before ‘void’
../include/openssl/crypto.h:482: error: expected ‘)’ before ‘const’
../include/openssl/crypto.h:483: error: expected ‘;’, ‘,’ or ‘)’ before ‘void’
../include/openssl/crypto.h:500: error: expected declaration specifiers or ‘...’ before ‘size_t’
../include/openssl/crypto.h:535: error: expected ‘)’ before ‘*’ token
In file included from cryptlib.h:74,
                 from cryptlib.c:117:
../include/openssl/bio.h:634: error: expected ‘)’ before ‘*’ token
../include/openssl/bio.h:706: error: expected ‘)’ before ‘*’ token
../include/openssl/bio.h:707: error: expected ‘)’ before ‘*’ token
In file included from ../include/openssl/err.h:127,
                 from cryptlib.h:75,
                 from cryptlib.c:117:
../include/openssl/lhash.h:186: error: expected declaration specifiers or ‘...’ before ‘FILE’
../include/openssl/lhash.h:187: error: expected declaration specifiers or ‘...’ before ‘FILE’
../include/openssl/lhash.h:188: error: expected declaration specifiers or ‘...’ before ‘FILE’
In file included from cryptlib.h:75,
                 from cryptlib.c:117:
../include/openssl/err.h:140:19: error: errno.h: No such file or directory
In file included from cryptlib.h:75,
                 from cryptlib.c:117:
../include/openssl/err.h:343: error: expected ‘)’ before ‘*’ token
cryptlib.c: In function ‘CRYPTO_THREADID_set_numeric’:
cryptlib.c:430: warning: incompatible implicit declaration of built-in function ‘memset’
cryptlib.c: In function ‘CRYPTO_THREADID_set_pointer’:
cryptlib.c:441: warning: incompatible implicit declaration of built-in function ‘memset’
cryptlib.c: In function ‘CRYPTO_THREADID_current’:
cryptlib.c:507: error: ‘errno’ undeclared (first use in this function)
cryptlib.c:507: error: (Each undeclared identifier is reported only once
cryptlib.c:507: error: for each function it appears in.)
cryptlib.c: In function ‘CRYPTO_THREADID_cpy’:
cryptlib.c:518: warning: incompatible implicit declaration of built-in function ‘memcpy’
cryptlib.c: In function ‘OPENSSL_showfatal’:
cryptlib.c:906: error: ‘stderr’ undeclared (first use in this function)
cryptlib.c: In function ‘OpenSSLDie’:
cryptlib.c:918: warning: incompatible implicit declaration of built-in function ‘abort’
cryptlib.c: In function ‘OPENSSL_stderr’:
cryptlib.c:926: error: ‘stderr’ undeclared (first use in this function)
make[1]: *** [cryptlib.o] Error 1
make: *** [build_crypto] Error 1
What can I fix it 

如果您知道请帮助我,请如何解决此错误。谢谢。

3 个答案:

答案 0 :(得分:0)

  

我尝试使用此http://x2on.de/2010/12/16/tutorial-script-for-building-openssl-for-ios-iphoneipad/编译openssl库但得到了

您的问题是由路径和sysroot问题引起的。从它的外观来看,那个剧本是一个可怕的黑客。

OpenSSL项目有一个脚本,用于设置环境并为iOS设备构建库。你可以在这里找到它:setenv-ios,sh。不幸的是,网上或其维基中没有文档。但是OpenSSL FIPS User Guide 2.0涵盖了它(见附录E)。

这是我用来构建库(使用脚本)的配方。确保OpenSSL tar球和脚本位于同一目录(下面的“root”目录)。

# Start fresh
$ rm -rf openssl-1.0.1e/
$ chmod a+x setenv-ios-11.sh

# From the 'root' directory
$ . ./setenv-ios-11.sh
$ tar xzf openssl-1.0.1e.tar.gz
$ cd openssl-1.0.1e/

$ perl -pi -e 's/install: all install_docs install_sw/install:install_docs install_sw/g' Makefile.org
$ ./config shared -no-ssl2 -no-ssl3 -no-comp -no-hw -no-engine --openssldir=/usr/local/ssl/ios-6.1

$ make depend
$ make all
$ sudo -E make install

请务必加入前导“。” (点)设置环境时。安装后,标题和库将位于/usr/local/ssl/ios-6.1

如果您有任何问题,请咨询OpenSSL FIPS User Guide 2.0,但忽略与FIPS相关的内容。

答案 1 :(得分:0)

根据您的需要,你可以考虑在你的项目中使用Cocoapods,然后你可以像这样使用pod:https://github.com/krzak/OpenSSL

只需添加到Podfile:

pod 'OpenSSL', :podspec => 'https://raw.github.com/krzak/OpenSSL/master/OpenSSL.podspec'

然后编码。

答案 2 :(得分:0)

如果同时安装了Windows SDK 10和Windows Driver SDK 10,也可能会发生错误。似乎VCVARS会在这种情况下设置错误的包含路径