im正在尝试从我的winsock程序发出任何HTTPS请求。我得出的结论是,我必须使用某些SSL连接,但是很难从头开始。因此,我找到了 lib,找到了一个Linux示例并尝试使用它。从https://github.com/openssl/openssl/tree/master/include下载了openssl文件夹,并将其粘贴到C:\MinGW\include
中,但是在编译(gcc clientHTTPS.c -o clientHTTPS.exe -l Ws2_32)
时,会从包含中获取一些错误。
有一些使用其他SSL库的win socket io示例?关于错误,我该如何解决?
错误:
gcc clientHTTP.c -o clientHTTP.exe -l Ws2_32
In file included from c:\mingw\include\openssl\opensslconf.h:13,
from c:\mingw\include\openssl\macros.h:10,
from c:\mingw\include\openssl\ssl.h:16,
from clientHTTP.c:3:
c:\mingw\include\openssl\configuration.h:27:1: error: expected identifier or '(' before '{' token
{- if (@{$config{openssl_sys_defines}}) {
^
c:\mingw\include\openssl\configuration.h:27:8: error: stray '@' in program
{- if (@{$config{openssl_sys_defines}}) {
^
c:\mingw\include\openssl\configuration.h:28:16: error: stray '@' in program
foreach (@{$config{openssl_sys_defines}}) {
^
c:\mingw\include\openssl\configuration.h:34:14: error: stray '@' in program
foreach (@{$config{openssl_api_defines}}) {
^
c:\mingw\include\openssl\configuration.h:38:9: error: stray '@' in program
if (@{$config{openssl_feature_defines}}) {
^
c:\mingw\include\openssl\configuration.h:39:16: error: stray '@' in program
foreach (@{$config{openssl_feature_defines}}) {
^
c:\mingw\include\openssl\configuration.h:49:1: error: expected identifier or '(' before '{' token
{- $config{processor} eq "386" ? "# define" : "# undef" -} I386_ONLY
^
c:\mingw\include\openssl\configuration.h:55:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
{- $config{bn_ll} ? "# define" : "# undef" -} BN_LLONG
^
c:\mingw\include\openssl\configuration.h:57:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
{- $config{b64l} ? "# define" : "# undef" -} SIXTY_FOUR_BIT_LONG
^
c:\mingw\include\openssl\configuration.h:58:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
{- $config{b64} ? "# define" : "# undef" -} SIXTY_FOUR_BIT
^
c:\mingw\include\openssl\configuration.h:59:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
{- $config{b32} ? "# define" : "# undef" -} THIRTY_TWO_BIT
^
In file included from c:\mingw\include\openssl\macros.h:11,
from c:\mingw\include\openssl\opensslconf.h:14,
from c:\mingw\include\openssl\macros.h:10,
from c:\mingw\include\openssl\ssl.h:16,
from clientHTTP.c:3:
c:\mingw\include\openssl\macros.h:104:6: error: token "{" is not valid in preprocessor expressions
# if OPENSSL_API_LEVEL > OPENSSL_CONFIGURED_API
^~~~~~~~~~~~~~~~~
c:\mingw\include\openssl\macros.h:112:6: error: token "{" is not valid in preprocessor expressions
# if OPENSSL_API_LEVEL > (OPENSSL_VERSION_MAJOR * 10000 + OPENSSL_VERSION_MINOR * 100)
^~~~~~~~~~~~~~~~~
c:\mingw\include\openssl\macros.h:116:6: error: token "{" is not valid in preprocessor expressions
# if OPENSSL_API_LEVEL < 30000 && OPENSSL_API_LEVEL >= 20000
^~~~~~~~~~~~~~~~~
c:\mingw\include\openssl\macros.h:120:6: error: token "{" is not valid in preprocessor expressions
# if OPENSSL_API_LEVEL < 908
^~~~~~~~~~~~~~~~~
c:\mingw\include\openssl\macros.h:139:6: error: token "{" is not valid in preprocessor expressions
# if OPENSSL_API_LEVEL >= 30000
^~~~~~~~~~~~~~~~~
c:\mingw\include\openssl\macros.h:149:6: error: token "{" is not valid in preprocessor expressions
# if OPENSSL_API_LEVEL >= 10101
^~~~~~~~~~~~~~~~~
c:\mingw\include\openssl\macros.h:159:6: error: token "{" is not valid in preprocessor expressions
# if OPENSSL_API_LEVEL >= 10100
^~~~~~~~~~~~~~~~~
c:\mingw\include\openssl\macros.h:169:6: error: token "{" is not valid in preprocessor expressions
# if OPENSSL_API_LEVEL >= 10002
^~~~~~~~~~~~~~~~~
c:\mingw\include\openssl\macros.h:179:6: error: token "{" is not valid in preprocessor expressions
# if OPENSSL_API_LEVEL >= 10001
^~~~~~~~~~~~~~~~~
c:\mingw\include\openssl\macros.h:189:6: error: token "{" is not valid in preprocessor expressions
# if OPENSSL_API_LEVEL >= 10000
^~~~~~~~~~~~~~~~~
c:\mingw\include\openssl\macros.h:199:6: error: token "{" is not valid in preprocessor expressions
# if OPENSSL_API_LEVEL >= 908
^~~~~~~~~~~~~~~~~
In file included from c:\mingw\include\openssl\opensslconf.h:13,
from c:\mingw\include\openssl\macros.h:10,
from c:\mingw\include\openssl\ssl.h:16,
from clientHTTP.c:3:
c:\mingw\include\openssl\configuration.h:59:62: error: expected ';' before 'typedef'
{- $config{b32} ? "# define" : "# undef" -} THIRTY_TWO_BIT
^
;
In file included from c:\mingw\include\openssl\params.h:15,
from c:\mingw\include\openssl\evp.h:27,
from c:\mingw\include\openssl\x509.h:24,
from c:\mingw\include\openssl\ssl.h:26,
from clientHTTP.c:3:
c:\mingw\include\openssl\bn.h:191:43: error: unknown type name 'BN_ULONG'
int BN_abs_is_word(const BIGNUM *a, const BN_ULONG w);
^~~~~~~~
c:\mingw\include\openssl\bn.h:194:39: error: unknown type name 'BN_ULONG'
int BN_is_word(const BIGNUM *a, const BN_ULONG w);
^~~~~~~~
In file included from c:\mingw\include\openssl\macros.h:11,
from c:\mingw\include\openssl\opensslconf.h:14,
from c:\mingw\include\openssl\macros.h:10,
from c:\mingw\include\openssl\ssl.h:16,
from clientHTTP.c:3:
c:\mingw\include\openssl\bn.h:201:6: error: token "{" is not valid in preprocessor expressions
# if OPENSSL_API_LEVEL > 908
^~~~~~~~~~~~~~~~~
In file included from c:\mingw\include\openssl\params.h:15,
from c:\mingw\include\openssl\evp.h:27,
from c:\mingw\include\openssl\x509.h:24,
from c:\mingw\include\openssl\ssl.h:26,
from clientHTTP.c:3:
c:\mingw\include\openssl\bn.h:228:22: error: unknown type name 'BN_ULONG'; did you mean 'PULONG'?
int BN_num_bits_word(BN_ULONG l);
^~~~~~~~
PULONG
c:\mingw\include\openssl\bn.h:282:1: error: unknown type name 'BN_ULONG'; did you mean 'PULONG'?
BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w);
^~~~~~~~
PULONG
c:\mingw\include\openssl\bn.h:282:39: error: unknown type name 'BN_ULONG'; did you mean 'PULONG'?
BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w);
^~~~~~~~
PULONG
c:\mingw\include\openssl\bn.h:283:1: error: unknown type name 'BN_ULONG'; did you mean 'PULONG'?
BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w);
^~~~~~~~
PULONG
c:\mingw\include\openssl\bn.h:283:33: error: unknown type name 'BN_ULONG'; did you mean 'PULONG'?
BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w);
^~~~~~~~
PULONG
c:\mingw\include\openssl\bn.h:284:28: error: unknown type name 'BN_ULONG'; did you mean 'PULONG'?
int BN_mul_word(BIGNUM *a, BN_ULONG w);
^~~~~~~~
PULONG
c:\mingw\include\openssl\bn.h:285:28: error: unknown type name 'BN_ULONG'; did you mean 'PULONG'?
int BN_add_word(BIGNUM *a, BN_ULONG w);
^~~~~~~~
PULONG
c:\mingw\include\openssl\bn.h:286:28: error: unknown type name 'BN_ULONG'; did you mean 'PULONG'?
int BN_sub_word(BIGNUM *a, BN_ULONG w);
^~~~~~~~
PULONG
c:\mingw\include\openssl\bn.h:287:28: error: unknown type name 'BN_ULONG'; did you mean 'PULONG'?
int BN_set_word(BIGNUM *a, BN_ULONG w);
^~~~~~~~
PULONG
c:\mingw\include\openssl\bn.h:288:1: error: unknown type name 'BN_ULONG'; did you mean 'PULONG'?
BN_ULONG BN_get_word(const BIGNUM *a);
^~~~~~~~
PULONG
c:\mingw\include\openssl\bn.h:304:37: error: unknown type name 'BN_ULONG'; did you mean 'PULONG'?
int BN_mod_exp_mont_word(BIGNUM *r, BN_ULONG a, const BIGNUM *p,
^~~~~~~~
PULONG
c:\mingw\include\openssl\bn.h:339:24: error: unknown type name 'BN_ULONG'; did you mean 'PULONG'?
void BN_consttime_swap(BN_ULONG swap, BIGNUM *a, BIGNUM *b, int nwords);
^~~~~~~~
PULONG
通常要使用任何C库,您需要头文件用于编译代码,和目标文件,通常打包成一个库,其中包含所使用的库代码链接并运行您的代码。不迟于C(或C ++)编程的任何课程的第二周,都应涵盖这一内容。
特别是对于OpenSSL,因为它可移植到许多不同的体系结构中,所以您不能原样使用上游源。您需要头文件针对您的系统类型定制和对象库针对您的系统类型编译,即Windows 32位或64位。 (即使在64位Windows上,IINM Cygwin也是32位的,但请自己检查。)执行以下任一操作:
下载整个上游树(您可以不用测试部分就可以做,但不会节省太多),并按照文件INSTALL(或INSTALL.W32或INSTALL.W64(如果适用)中的说明)运行构建过程。适用于低于1.1.0的版本,但现在已经过时了,尽管您仍然可以根据需要获得它们)
获得已经由其他人完成的构建。我喜欢(并使用)http://www.slproweb.com/products/Win32OpenSSL.html,它为Windows提供了免费的最新OpenSSL版本,并打包到一个不错的安装程序中,该安装程序遵循Windows关于将文件,注册表项,环境变量放在何处的约定。