Unable to make on MingW due to unrecognized option

2019-07-29 13:21发布

问题:

I have no clue why it doesn't work.. Normally this is supposed to be the easy part, I'm trying to get this fucked up thing to work for days and it still doesn't do anything. Please Help me because I'm very close to throwing this computer through the window.

> C:\...\Downloads\crypto50>mingw32-make -f 

> GNUmakefile process_begin:
> CreateProcess(NULL, uname, ...) failed. process_begin:
> CreateProcess(NULL, uname, ...) failed. process_begin:
> CreateProcess(NULL, uname, ...) failed. g++ -g -mbnu210 -c md5.cpp
> g++: error: unrecognized command line option '-mbnu210'
> GNUmakefile:58: recipe for target 'md5.o' failed mingw32-make: ***
> [md5.o] Error 1

And when I try to follow this guys tutorial https://sites.google.com/site/ievgensychov/cryptopp this is what happens:

> g++ -DNDEBUG -g -O2 -c shacal2.cpp g++ -DNDEBUG -g -O2 -c seed.cpp g++
> -DNDEBUG -g -O2 -c shark.cpp In file included from shark.h:9:0,
>                  from shark.cpp:4: secblock.h: In instantiation of 'CryptoPP::AllocatorWithCleanup<T, T_Align16>::p ointer
> CryptoPP::AllocatorWithCleanup<T,
> T_Align16>::allocate(CryptoPP::Allocato rWithCleanup<T,
> T_Align16>::size_type, const void*) [with T = unsigned char; boo l
> T_Align16 = false; CryptoPP::AllocatorWithCleanup<T,
> T_Align16>::pointer = uns igned char*;
> CryptoPP::AllocatorWithCleanup<T, T_Align16>::size_type = unsigned
> int]': secblock.h:247:25:   required from 'CryptoPP::SecBlock<T,
> A>::SecBlock(CryptoPP: :SecBlock<T, A>::size_type) [with T = unsigned
> char; A = CryptoPP::AllocatorWith Cleanup<unsigned char>;
> CryptoPP::SecBlock<T, A>::size_type = unsigned int]' algparam.h:17:2: 
> required from here secblock.h:91:14: error: 'CheckSize' was not
> declared in this scope, and no decl arations were found by
> argument-dependent lookup at the point of instantiation [
> -fpermissive]    CheckSize(n);
>               ^ secblock.h:91:14: note: declarations in dependent base 'CryptoPP::AllocatorBase< unsigned char>' are not found by unqualified
> lookup secblock.h:91:14: note: use 'this->CheckSize' instead
> secblock.h: In instantiation of 'CryptoPP::AllocatorWithCleanup<T,
> T_Align16>::p ointer CryptoPP::AllocatorWithCleanup<T,
> T_Align16>::allocate(CryptoPP::Allocato rWithCleanup<T,
> T_Align16>::size_type, const void*) [with T = unsigned char; boo l
> T_Align16 = true; CryptoPP::AllocatorWithCleanup<T,
> T_Align16>::pointer = unsi gned char*;
> CryptoPP::AllocatorWithCleanup<T, T_Align16>::size_type = unsigned i
> nt]': secblock.h:247:25:   required from 'CryptoPP::SecBlock<T,
> A>::SecBlock(CryptoPP: :SecBlock<T, A>::size_type) [with T = unsigned
> char; A = CryptoPP::AllocatorWith Cleanup<unsigned char, true>;
> CryptoPP::SecBlock<T, A>::size_type = unsigned int ]' modes.h:63:34:  
> required from here secblock.h:91:14: error: 'CheckSize' was not
> declared in this scope, and no decl arations were found by
> argument-dependent lookup at the point of instantiation [
> -fpermissive] secblock.h:91:14: note: declarations in dependent base 'CryptoPP::AllocatorBase< unsigned char>' are not found by unqualified
> lookup secblock.h:91:14: note: use 'this->CheckSize' instead
> secblock.h: In instantiation of 'CryptoPP::AllocatorWithCleanup<T,
> T_Align16>::p ointer CryptoPP::AllocatorWithCleanup<T,
> T_Align16>::allocate(CryptoPP::Allocato rWithCleanup<T,
> T_Align16>::size_type, const void*) [with T = long long unsigned  int;
> bool T_Align16 = false; CryptoPP::AllocatorWithCleanup<T,
> T_Align16>::poin ter = long long unsigned int*;
> CryptoPP::AllocatorWithCleanup<T, T_Align16>::siz e_type = unsigned
> int]': secblock.h:247:25:   required from 'CryptoPP::SecBlock<T,
> A>::SecBlock(CryptoPP: :SecBlock<T, A>::size_type) [with T = long long
> unsigned int; A = CryptoPP::Allo catorWithCleanup<long long unsigned
> int>; CryptoPP::SecBlock<T, A>::size_type = unsigned int]'
> shark.h:22:27:   required from 'CryptoPP::BlockCipherFinal<DIR,
> BASE>::BlockCiph erFinal() [with CryptoPP::CipherDir DIR =
> (CryptoPP::CipherDir)0u; BASE = Crypto PP::SHARK::Enc]'
> shark.cpp:43:20:   required from here secblock.h:91:14: error:
> 'CheckSize' was not declared in this scope, and no decl arations were
> found by argument-dependent lookup at the point of instantiation [
> -fpermissive] secblock.h:91:14: note: declarations in dependent base 'CryptoPP::AllocatorBase< long long unsigned int>' are not found by
> unqualified lookup secblock.h:91:14: note: use 'this->CheckSize'
> instead GNUmakefile:73: recipe for target 'shark.o' failed
> mingw32-make: *** [shark.o] Error 1
> 
> c:\cryptopp>mingw32-make test g++ -DNDEBUG -g -O2 -c shark.cpp In file
> included from shark.h:9:0,
>                  from shark.cpp:4: secblock.h: In instantiation of 'CryptoPP::AllocatorWithCleanup<T, T_Align16>::p ointer
> CryptoPP::AllocatorWithCleanup<T,
> T_Align16>::allocate(CryptoPP::Allocato rWithCleanup<T,
> T_Align16>::size_type, const void*) [with T = unsigned char; boo l
> T_Align16 = false; CryptoPP::AllocatorWithCleanup<T,
> T_Align16>::pointer = uns igned char*;
> CryptoPP::AllocatorWithCleanup<T, T_Align16>::size_type = unsigned
> int]': secblock.h:247:25:   required from 'CryptoPP::SecBlock<T,
> A>::SecBlock(CryptoPP: :SecBlock<T, A>::size_type) [with T = unsigned
> char; A = CryptoPP::AllocatorWith Cleanup<unsigned char>;
> CryptoPP::SecBlock<T, A>::size_type = unsigned int]' algparam.h:17:2: 
> required from here secblock.h:91:14: error: 'CheckSize' was not
> declared in this scope, and no decl arations were found by
> argument-dependent lookup at the point of instantiation [
> -fpermissive]    CheckSize(n);
>               ^ secblock.h:91:14: note: declarations in dependent base 'CryptoPP::AllocatorBase< unsigned char>' are not found by unqualified
> lookup secblock.h:91:14: note: use 'this->CheckSize' instead
> secblock.h: In instantiation of 'CryptoPP::AllocatorWithCleanup<T,
> T_Align16>::p ointer CryptoPP::AllocatorWithCleanup<T,
> T_Align16>::allocate(CryptoPP::Allocato rWithCleanup<T,
> T_Align16>::size_type, const void*) [with T = unsigned char; boo l
> T_Align16 = true; CryptoPP::AllocatorWithCleanup<T,
> T_Align16>::pointer = unsi gned char*;
> CryptoPP::AllocatorWithCleanup<T, T_Align16>::size_type = unsigned i
> nt]': secblock.h:247:25:   required from 'CryptoPP::SecBlock<T,
> A>::SecBlock(CryptoPP: :SecBlock<T, A>::size_type) [with T = unsigned
> char; A = CryptoPP::AllocatorWith Cleanup<unsigned char, true>;
> CryptoPP::SecBlock<T, A>::size_type = unsigned int ]' modes.h:63:34:  
> required from here secblock.h:91:14: error: 'CheckSize' was not
> declared in this scope, and no decl arations were found by
> argument-dependent lookup at the point of instantiation [
> -fpermissive] secblock.h:91:14: note: declarations in dependent base 'CryptoPP::AllocatorBase< unsigned char>' are not found by unqualified
> lookup secblock.h:91:14: note: use 'this->CheckSize' instead
> secblock.h: In instantiation of 'CryptoPP::AllocatorWithCleanup<T,
> T_Align16>::p ointer CryptoPP::AllocatorWithCleanup<T,
> T_Align16>::allocate(CryptoPP::Allocato rWithCleanup<T,
> T_Align16>::size_type, const void*) [with T = long long unsigned  int;
> bool T_Align16 = false; CryptoPP::AllocatorWithCleanup<T,
> T_Align16>::poin ter = long long unsigned int*;
> CryptoPP::AllocatorWithCleanup<T, T_Align16>::siz e_type = unsigned
> int]': secblock.h:247:25:   required from 'CryptoPP::SecBlock<T,
> A>::SecBlock(CryptoPP: :SecBlock<T, A>::size_type) [with T = long long
> unsigned int; A = CryptoPP::Allo catorWithCleanup<long long unsigned
> int>; CryptoPP::SecBlock<T, A>::size_type = unsigned int]'
> shark.h:22:27:   required from 'CryptoPP::BlockCipherFinal<DIR,
> BASE>::BlockCiph erFinal() [with CryptoPP::CipherDir DIR =
> (CryptoPP::CipherDir)0u; BASE = Crypto PP::SHARK::Enc]'
> shark.cpp:43:20:   required from here secblock.h:91:14: error:
> 'CheckSize' was not declared in this scope, and no decl arations were
> found by argument-dependent lookup at the point of instantiation [
> -fpermissive] secblock.h:91:14: note: declarations in dependent base 'CryptoPP::AllocatorBase< long long unsigned int>' are not found by
> unqualified lookup secblock.h:91:14: note: use 'this->CheckSize'
> instead GNUmakefile:73: recipe for target 'shark.o' failed
> mingw32-make: *** [shark.o] Error 1
> 
> c:\cryptopp>mkdir include\cryptopp
> 
> c:\cryptopp>mkdir lib
> 
> c:\cryptopp>copy *.h include\cryptopp 3way.h adler32.h aes.h algebra.h
> algparam.h arc4.h argnames.h asn.h authenc.h base32.h base64.h
> basecode.h bench.h blowfish.h blumshub.h camellia.h cast.h cbcmac.h
> ccm.h channels.h cmac.h config.h cpu.h crc.h cryptlib.h default.h
> des.h dh.h dh2.h dll.h dmac.h dsa.h eax.h ec2n.h eccrypto.h ecp.h
> elgamal.h emsa2.h eprecomp.h esign.h factory.h files.h filters.h
> fips140.h fltrimpl.h gcm.h gf256.h gf2n.h gf2_32.h gfpcrypt.h gost.h
> gzip.h hex.h hmac.h hrtimer.h ida.h idea.h integer.h iterhash.h
> lubyrack.h luc.h mars.h md2.h md4.h md5.h mdc.h misc.h modarith.h
> modes.h modexppc.h mqueue.h mqv.h nbtheory.h network.h nr.h oaep.h
> oids.h osrng.h panama.h pch.h pkcspad.h polynomi.h pssr.h pubkey.h
> pwdbased.h queue.h rabin.h randpool.h rc2.h rc5.h rc6.h resource.h
> rijndael.h ripemd.h rng.h rsa.h rw.h safer.h salsa.h seal.h secblock.h
> seckey.h seed.h serpent.h serpentp.h sha.h shacal2.h shark.h simple.h
> skipjack.h smartptr.h socketft.h sosemanuk.h square.h stdcpp.h
> strciphr.h tea.h tiger.h trdlocal.h trunhash.h ttmac.h twofish.h
> validate.h vmac.h wait.h wake.h whrlpool.h winpipes.h words.h xtr.h
> xtrcrypt.h zdeflate.h zinflate.h zlib.h
>       134 file(s) copied.
> 
> c:\cryptopp>copy *.a lib
> *.a Het systeem kan het opgegeven bestand niet vinden.
>         0 file(s) copied.

回答1:

I'm trying to get this fucked up thing to work for days and it still doesn't do anything...

It looks like you have two problems.


g++: error: unrecognized command line option '-mbnu210'

This is from line 72 of GNUMakefile:

ifeq ($(UNAME),) # for DJGPP, where uname doesn't exist
CXXFLAGS += -mbnu210
else
CXXFLAGS += -pipe
endif

It sounds like your MinGW is not set up properly. More specifically, either (1) mingw-developer-tools is not installed (via mingw-get), or (2) your paths are not quite right and lack the C:\MinGW\msys\1.0\bin path (that's where uname lives).

You might try something like the following before the DJGPP test. Open the GNUMakefile, and add the test and assignment.

ifeq ($(IS_MINGW),1)
UNAME=mingw
endif

I would add it at around line 28, before the test for X86 (i.e., line 29 that starts with ifeq ($(ISX86),1)). You could also add it at around line 71 after the X86 block but before the DJGPP test.

One other thing to keep in mind: IS_MINGW is set on line 17 with the following:

IS_MINGW = $(shell $(CXX) -dumpmachine 2>&1 | $(EGREP) -c "mingw")

If IS_MINGW is not set correctly, then you might want to set it to 1 unconditionally.


> g++ -DNDEBUG -g -O2 -c shacal2.cpp g++ -DNDEBUG -g -O2 -c seed.cpp g++
> -DNDEBUG -g -O2 -c shark.cpp In file included from shark.h:9:0,
>                  from shark.cpp:4: secblock.h: In instantiation of 
> 'CryptoPP::AllocatorWithCleanup<T, T_Align16>::p ointer
> CryptoPP::AllocatorWithCleanup<T,
> T_Align16>::allocate(CryptoPP::Allocato rWithCleanup<T,
> T_Align16>::size_type, const void*) [with T = unsigned char; boo l
> T_Align16 = false; CryptoPP::AllocatorWithCleanup<T,
> T_Align16>::pointer = uns igned char*;
> CryptoPP::AllocatorWithCleanup<T, T_Align16>::size_type = unsigned
> int]': secblock.h:247:25:   required from 'CryptoPP::SecBlock<T,
> A>::SecBlock(CryptoPP: :SecBlock<T, A>::size_type) [with T = unsigned
> char; A = CryptoPP::AllocatorWith Cleanup<unsigned char>;
> CryptoPP::SecBlock<T, A>::size_type = unsigned int]' algparam.h:17:2: 
> required from here secblock.h:91:14: error: 'CheckSize' was not
> declared in this scope, and no decl arations were found by
> argument-dependent lookup at the point of instantiation [
> -fpermissive]    CheckSize(n);
>               ^ secblock.h:91:14: note: declarations in dependent base 
> 'CryptoPP::AllocatorBase< unsigned char>' are not found by unqualified
> lookup secblock.h:91:14: note: use 'this->CheckSize' instead

Stop using Crypto++ 5.0, and use the latest version of Crypto++ (either 5.6.2 from the website, or checkout the latest Crypto++ from SVN).

The problem is argument dependent name lookups. The problem was fixed at revision 522 and revision 539. The problem did not show its head until recently (relatively speaking), with later versions of GCC (circa GCC 4.7 or so).

If you check the latest secblock.h on Sourceforge, then you will see the this particular issue was already fixed by changing the statement to this->CheckSize() as suggested by GCC.

If you have some straglers that were not fixed, then add this-> to the problem statement. For example, in the compile problem above, you would open secblock.h, scroll down to line 91, and then change the statement to this->CheckSize().