Name is carl
Name is carl

Reputation: 6051

Openssl fails to build with mingw: "does not give a valid preprocessing token"

I'm trying to build openssl 1.0.1x with a wide variety of mingw flavors and I get the following error.

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); \
        ^

Do you have an idea what's wrong?

Upvotes: 0

Views: 528

Answers (1)

Name is carl
Name is carl

Reputation: 6051

According to this, mingw headers redefines openssl symbols.

You need to undefine them.

Add the following to 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

Upvotes: 1

Related Questions