Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile MinGW failed #5327

Closed
willin opened this issue Feb 12, 2018 · 15 comments
Closed

Compile MinGW failed #5327

willin opened this issue Feb 12, 2018 · 15 comments

Comments

@willin
Copy link

@willin willin commented Feb 12, 2018

$ ./config
Operating system: i686-whatever-mingw
Configuring for mingw
Configuring for mingw
    no-ec_nistp_64_gcc_128 [default]  OPENSSL_NO_EC_NISTP_64_GCC_128 (skip dir)
    no-gmp          [default]  OPENSSL_NO_GMP (skip dir)
    no-jpake        [experimental] OPENSSL_NO_JPAKE (skip dir)
    no-krb5         [krb5-flavor not specified] OPENSSL_NO_KRB5
    no-md2          [default]  OPENSSL_NO_MD2 (skip dir)
    no-rc5          [default]  OPENSSL_NO_RC5 (skip dir)
    no-rfc3779      [default]  OPENSSL_NO_RFC3779 (skip dir)
    no-sctp         [default]  OPENSSL_NO_SCTP (skip dir)
    no-shared       [default]
    no-store        [experimental] OPENSSL_NO_STORE (skip dir)
    no-unit-test    [default]  OPENSSL_NO_UNIT_TEST (skip dir)
    no-zlib         [default]
    no-zlib-dynamic [default]
IsMK1MF=0
CC            =gcc
CFLAG         =-DOPENSSL_THREADS -D_MT -DDSO_WIN32 -DL_ENDIAN -DWIN32_LEAN_AND_MEAN -fomit-frame-pointer -O3 -march=i486 -Wall -DOPENSSL_BN_ASM_PART_WORDS -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DRMD160_ASM -DAES_ASM -DVPAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM
EX_LIBS       =-lws2_32 -lgdi32 -lcrypt32
CPUID_OBJ     =x86cpuid.o
BN_ASM        =bn-586.o co-586.o x86-mont.o x86-gf2m.o
DES_ENC       =des-586.o crypt586.o
AES_ENC       =aes-586.o vpaes-x86.o aesni-x86.o
BF_ENC        =bf-586.o
CAST_ENC      =cast-586.o
RC4_ENC       =rc4-586.o
RC5_ENC       =rc5-586.o
MD5_OBJ_ASM   =md5-586.o
SHA1_OBJ_ASM  =sha1-586.o sha256-586.o sha512-586.o
RMD160_OBJ_ASM=rmd-586.o
CMLL_ENC      =cmll-x86.o
MODES_OBJ     =ghash-x86.o
ENGINES_OBJ   =
PROCESSOR     =
RANLIB        =true
ARFLAGS       =
PERL          =perl
THIRTY_TWO_BIT mode
DES_PTR used
DES_RISC1 used
DES_UNROLL used
BN_LLONG mode
RC4_INDEX mode
RC4_CHUNK is undefined
e_os2.h => include/openssl/e_os2.h
making links in crypto...
make[1]: Entering directory `/c/dev/coindeps32/openssl-1.0.1p-mgw/crypto'
crypto.h => ../include/openssl/crypto.h
opensslv.h => ../include/openssl/opensslv.h
opensslconf.h => ../include/openssl/opensslconf.h
ebcdic.h => ../include/openssl/ebcdic.h
symhacks.h => ../include/openssl/symhacks.h
ossl_typ.h => ../include/openssl/ossl_typ.h
constant_time_test.c => ../test/constant_time_test.c
making links in crypto/objects...
make[2]: Entering directory `/c/dev/coindeps32/openssl-1.0.1p-mgw/crypto/objects'
objects.h => ../../include/openssl/objects.h
obj_mac.h => ../../include/openssl/obj_mac.h
make[2]: Leaving directory `/c/dev/coindeps32/openssl-1.0.1p-mgw/crypto
.....
.....
.....
 /c/dev/coindeps32/openssl-1.0.1p-mgw
$ make
making all in crypto...
make[1]: Entering directory `/c/dev/coindeps32/openssl-1.0.1p-mgw/crypto'
perl ../util/mkbuildinf.pl "gcc -I. -I.. -I../include  -DOPENSSL_THREADS -D_MT -DDSO_WIN32 -DL_ENDIAN -DWIN32_LEAN_AND_MEAN -fomit-frame-pointer -O3 -march=i486 -Wall -DOPENSSL_BN_ASM_PART_WORDS -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DRMD160_ASM -DAES_ASM -DVPAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM" "mingw" >buildinf.h
gcc -I. -I.. -I../include  -DOPENSSL_THREADS -D_MT -DDSO_WIN32 -DL_ENDIAN -DWIN32_LEAN_AND_MEAN -fomit-frame-pointer -O3 -march=i486 -Wall -DOPENSSL_BN_ASM_PART_WORDS -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DRMD160_ASM -DAES_ASM -DVPAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM   -c -o cryptlib.o cryptlib.c
cryptlib.c: In function 'OPENSSL_isservice':
cryptlib.c:814:27: error: 'ERROR_INSUFFICIENT_BUFFER' undeclared (first use in this function)
         GetLastError() != ERROR_INSUFFICIENT_BUFFER)
                           ^~~~~~~~~~~~~~~~~~~~~~~~~
cryptlib.c:814:27: note: each undeclared identifier is reported only once for each function it appears in
make[1]: *** [cryptlib.o] Error 1
make[1]: Leaving directory `/c/dev/coindeps32/openssl-1.0.1p-mgw/crypto'
make: *** [build_crypto] Error 1
@levitte

This comment has been minimized.

Copy link
Member

@levitte levitte commented Feb 12, 2018

1.0.1 is a version we don't support any more. Have you checked if you get the same error with 1.0.2 or newer?

@willin

This comment has been minimized.

Copy link
Author

@willin willin commented Feb 12, 2018

@levitte same

 /c/dev/coindeps32/openssl-1.0.2n-mgw
$ make
making all in crypto...
make[1]: Entering directory `/c/dev/coindeps32/openssl-1.0.2n-mgw/crypto'
perl ../util/mkbuildinf.pl "gcc -I. -I.. -I../include  -DOPENSSL_THREADS -D_MT -DDSO_WIN32 -DL_ENDIAN -DWIN32_LEAN_AND_MEAN -fomit-frame-pointer -O3 -march=i486 -Wall -DOPENSSL_BN_ASM_PART_WORDS -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m -DRC4_ASM -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DRMD160_ASM -DAES_ASM -DVPAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM" "mingw" >buildinf.h
gcc -I. -I.. -I../include  -DOPENSSL_THREADS -D_MT -DDSO_WIN32 -DL_ENDIAN -DWIN32_LEAN_AND_MEAN -fomit-frame-pointer -O3 -march=i486 -Wall -DOPENSSL_BN_ASM_PART_WORDS -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m -DRC4_ASM -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DRMD160_ASM -DAES_ASM -DVPAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM   -c -o cryptlib.o cryptlib.c
cryptlib.c: In function 'OPENSSL_isservice':
cryptlib.c:840:27: error: 'ERROR_INSUFFICIENT_BUFFER' undeclared (first use in this function)
         GetLastError() != ERROR_INSUFFICIENT_BUFFER)
                           ^~~~~~~~~~~~~~~~~~~~~~~~~
cryptlib.c:840:27: note: each undeclared identifier is reported only once for each function it appears in
make[1]: *** [cryptlib.o] Error 1
make[1]: Leaving directory `/c/dev/coindeps32/openssl-1.0.2n-mgw/crypto'
make: *** [build_crypto] Error 1
@willin

This comment has been minimized.

Copy link
Author

@willin willin commented Feb 12, 2018

https://github.com/openssl/openssl/blob/master/crypto/cryptlib.c#L151

ERROR_INSUFFICIENT_BUFFER not defined before use.

@mattcaswell

This comment has been minimized.

Copy link
Member

@mattcaswell mattcaswell commented Feb 12, 2018

This works fine for me (1.0.2n, using 32-bit mingw). Build completes successfully and tests pass. Please can you tell us a bit more about your environment. What do gcc --version and perl --version report. Are you using MSYS2 for your shell?

@dot-asm

This comment has been minimized.

Copy link
Contributor

@dot-asm dot-asm commented Feb 13, 2018

gcc -dM -E -x c /dev/null | grep __MINGW. If it gives no reading, then it's wrong compiler. In MSYS2 you can have compiler on your $PATH that targets MSYS itself, you can have compiler that target 32-bit mingw, and you can have compiler that targets 64-bit mingw. Last one is one to use with mingw64 OpenSSL target, one before last one, with mingw OpenSSL target, and that's it. They have to much to work, but how to get corresponding compilers on $PATH is exercise for user.

@dot-asm dot-asm closed this Feb 13, 2018
@JagDhillon

This comment has been minimized.

Copy link

@JagDhillon JagDhillon commented Mar 28, 2018

$ gcc -dM -E -x c /dev/null | grep __MINGW returns
#define __MINGW32__ 1

$ gcc --version returns
gcc.exe (MinGW.org GCC-6.3.0-1) 6.3.0

$ perl --version returns
This is perl, v5.8.8 built for msys-64int

I am encountering the same issue as willin:
cryptlib.c:814:27: error: 'ERROR_INSUFFICIENT_BUFFER' undeclared (first use in this function)

It seems the C compiler cannot locate the Windows header files.... in this case winerror.h

@nskforward

This comment has been minimized.

Copy link

@nskforward nskforward commented Mar 28, 2018

I have the same issue with openssl-1.0.2o

$ gcc -dM -E -x c /dev/null | grep __MINGW
#define __MINGW32__ 1
$ gcc --version
gcc.exe (MinGW.org GCC-6.3.0-1) 6.3.0
$ perl --version
This is perl, v5.8.8 built for msys-64int
@dot-asm

This comment has been minimized.

Copy link
Contributor

@dot-asm dot-asm commented Mar 28, 2018

Well, it still doesn't quite make it OpenSSL problem. In the essence we stand for source code and you stand for working toolchain. It's right compiler, but the fact that ERROR_INSUFFICIENT_BUFFER, a common WIN32 error, remains undefined suggests that your headers are not in shape. Note that mingw targets are exercised by travis CI on each commit... I also have some quite old mingw installation and can't confirm the problem...

@interhawk

This comment has been minimized.

Copy link

@interhawk interhawk commented Apr 5, 2018

I'm having the same issue as well. Has anyone found a way around this they can share?

@mattcaswell

This comment has been minimized.

Copy link
Member

@mattcaswell mattcaswell commented Apr 6, 2018

$ perl --version
This is perl, v5.8.8 built for msys-64int

That's a pre-historic version of perl, and nothing like what I have in my (working) environment:

$ perl --version
This is perl 5, version 24, subversion 1 (v5.24.1) built for x86_64-msys-thread-multi

Are you using MSYS or MSYS2? You should use the latter. The former just won't work.

@blefev

This comment has been minimized.

Copy link

@blefev blefev commented May 16, 2018

I fixed this by downgrading MinGW's w32api:
mingw-get upgrade "w32api<5.0.2"

@crypto3

This comment has been minimized.

Copy link

@crypto3 crypto3 commented May 28, 2018

mingw-get upgrade "w32api<5.0.2"

it worked for me, thanks blefev!

@bebetor

This comment has been minimized.

Copy link

@bebetor bebetor commented Jun 26, 2018

thanks for the help blefev, it works perfect

@e2iplayer

This comment has been minimized.

Copy link

@e2iplayer e2iplayer commented Jan 28, 2019

Same here. Thank you for the information.

@0xAA55

This comment has been minimized.

Copy link

@0xAA55 0xAA55 commented Feb 22, 2019

This can be fixed by just adding #include<winerror.h> to cryptlib.c at line 812 since ERROR_INSUFFICIENT_BUFFER were appearing at line 840. No need to downgrade mingw

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
You can’t perform that action at this time.