Openssl无法使用mingw构建:“不提供有效的预处理令牌”

时间:2014-06-09 11:31:00

标签: openssl mingw

我尝试使用各种openssl版本构建mingw 1.0.1x,我收到以下错误。

In file included from \android\external\openssl\crypto\er
\err_all.c:60:0:
/android/external/openssl/crypto/../include/openssl/ocsp.
:539:24: error: pasting ")" and "_new" does not give a valid preprocessing token
 DECLARE_ASN1_FUNCTIONS(OCSP_RESPONSE)
                        ^
/android/external/openssl/crypto/../include/openssl/asn1.
:333:8: note: in definition of macro 'DECLARE_ASN1_ALLOC_FUNCTIONS_name'
  type *name##_new(void); \
        ^
/android/external/openssl/crypto/../include/openssl/asn1.
:302:38: note: in expansion of macro 'DECLARE_ASN1_FUNCTIONS_name'
 #define DECLARE_ASN1_FUNCTIONS(type) DECLARE_ASN1_FUNCTIONS_name(type, type)
                                      ^
/android/external/openssl/crypto/../include/openssl/ocsp.
:539:1: note: in expansion of macro 'DECLARE_ASN1_FUNCTIONS'
 DECLARE_ASN1_FUNCTIONS(OCSP_RESPONSE)
 ^
/android/external/openssl/crypto/../include/openssl/ocsp.
:539:24: error: pasting ")" and "_free" does not give a valid preprocessing token
 DECLARE_ASN1_FUNCTIONS(OCSP_RESPONSE)
                        ^
/android/external/openssl/crypto/../include/openssl/asn1.
:334:7: note: in definition of macro 'DECLARE_ASN1_ALLOC_FUNCTIONS_name'
  void name##_free(type *a);
       ^
/android/external/openssl/crypto/../include/openssl/asn1.
:302:38: note: in expansion of macro 'DECLARE_ASN1_FUNCTIONS_name'
 #define DECLARE_ASN1_FUNCTIONS(type) DECLARE_ASN1_FUNCTIONS_name(type, type)
                                      ^
/android/external/openssl/crypto/../include/openssl/ocsp.
:539:1: note: in expansion of macro 'DECLARE_ASN1_FUNCTIONS'
 DECLARE_ASN1_FUNCTIONS(OCSP_RESPONSE)
 ^
/android/external/openssl/crypto/../include/openssl/asn1.
:316:8: error: pasting "d2i_" and "(" does not give a valid preprocessing token
  type *d2i_##name(type **a, const unsigned char **in, long len); \
        ^

你知道什么是错的吗?

1 个答案:

答案 0 :(得分:1)

根据this,mingw标题重新定义了openssl符号。

你需要取消定义它们。

将以下内容添加到openssl/include/openssl/ocsp.h

#if defined(OPENSSL_SYS_WINDOWS)
#include <windows.h>
#undef X509_NAME
#undef X509_EXTENSIONS
#undef X509_CERT_PAIR
#undef PKCS7_ISSUER_AND_SERIAL
#undef OCSP_REQUEST
#undef OCSP_RESPONSE
#endif