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

Building cryptest.exe fails on MinGW-w64 #28

Closed
IlyaBizyaev opened this issue Aug 6, 2015 · 70 comments
Closed

Building cryptest.exe fails on MinGW-w64 #28

IlyaBizyaev opened this issue Aug 6, 2015 · 70 comments

Comments

@IlyaBizyaev
Copy link

g++ -DNDEBUG -g2 -O3 -march=native -Wall -Wextra -Wno-type-limits -Wno-unknown-pragmas -pipe -c validat0.cpp
validat0.cpp: In function 'bool TestSettings()':
validat0.cpp:27:47: error: call of overloaded 'memcpy_s(CryptoPP::word32*, long long unsigned int, const char [5], int)' is ambiguous
  memcpy_s(&w, sizeof(w), "\x01\x02\x03\x04", 4);
                                               ^
validat0.cpp:27:47: note: candidates are:
In file included from stdcpp.h:12:0,
                 from validat0.cpp:6:
c:/MinGW-w64/mingw64/x86_64-w64-mingw32/include/string.h:42:27: note: errno_t memcpy_s(void*, size_t, const void*, size_t)
   _CRTIMP errno_t __cdecl memcpy_s (void *_dest,size_t _numberOfElements,const
void *_src,size_t _count);
                           ^
In file included from validat0.cpp:7:0:
misc.h:201:13: note: void CryptoPP::memcpy_s(void*, size_t, const void*, size_t)

 inline void memcpy_s(void *dest, size_t sizeInBytes, const void *src, size_t co
unt)
             ^
make: *** [validat0.o] Error 1

g++ -v output:

Using built-in specs.
COLLECT_GCC=c:\MinGW-w64\mingw64\bin\g++.exe
COLLECT_LTO_WRAPPER=c:/MinGW-w64/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/4.9.2/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../../../src/gcc-4.9.2/configure --host=x86_64-w64-mingw32 --build=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --prefix=/mingw64 --with-sysroot=/c/mingw492/x86_64-492-win32-seh-rt_v4-rev3/mingw64 --with-gxx-include-dir=/mingw64/x86_64-w64-mingw32/include/c++ --enable-shared --enable-static --disable-multilib --enable-languages=ada,c,c++,fortran,objc,obj-c++,lto --enable-libstdcxx-time=yes --enable-threads=win32 --enable-libgomp --enable-libatomic --enable-lto --enable-graphite --enable-checking=release --enable-fully-dynamic-string --enable-version-specific-runtime-libs --disable-isl-version-check --disable-cloog-version-check --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-bootstrap --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-gnu-as --with-gnu-ld --with-arch=nocona --with-tune=core2 --with-libiconv --with-system-zlib --with-gmp=/c/mingw492/prerequisites/x86_64-w64-mingw32-static --with-mpfr=/c/mingw492/prerequisites/x86_64-w64-mingw32-static --with-mpc=/c/mingw492/prerequisites/x86_64-w64-mingw32-static --with-isl=/c/mingw492/prerequisites/x86_64-w64-mingw32-static --with-cloog=/c/mingw492/prerequisites/x86_64-w64-mingw32-static --enable-cloog-backend=isl --with-pkgversion='x86_64-win32-seh-rev3, Built by MinGW-W64 project' --with-bugurl=http://sourceforge.net/projects/mingw-w64 CFLAGS='-O2 -pipe -I/c/mingw492/x86_64-492-win32-seh-rt_v4-rev3/mingw64/opt/include -I/c/mingw492/prerequisites/x86_64-zlib-static/include -I/c/mingw492/prerequisites/x86_64-w64-mingw32-static/include' CXXFLAGS='-O2 -pipe -I/c/mingw492/x86_64-492-win32-seh-rt_v4-rev3/mingw64/opt/include -I/c/mingw492/prerequisites/x86_64-zlib-static/include -I/c/mingw492/prerequisites/x86_64-w64-mingw32-static/include' CPPFLAGS= LDFLAGS='-pipe -L/c/mingw492/x86_64-492-win32-seh-rt_v4-rev3/mingw64/opt/lib -L/c/mingw492/prerequisites/x86_64-zlib-static/lib -L/c/mingw492/prerequisites/x86_64-w64-mingw32-static/lib '
Thread model: win32
gcc version 4.9.2 (x86_64-win32-seh-rev3, Built by MinGW-W64 project)
@ThatAIGeek
Copy link

so did someone fixed that?

@fleith
Copy link

fleith commented Oct 21, 2015

To fix this error you can put in front of the function memcpy_s your namespace. If you put CryptoPP::memcpy_s the compiler doesn't have ambiguous problem.

@noloader
Copy link
Collaborator

@IlyaBizyaev - forgive my ignorance... When I search MinGW's site for the 64-bit download, I cannot find it. Confer: search: mingw64. I did find a quote: "In the future, other subsystems such as mingw64 may be supported...". The best I can tell, there is no MinGW-64.

Where, exactly, does MinGW make the download available?

(I can see where this ambiguity comes from, and we are going to clear it. I'm asking about the download because I want to get a test environment setup for this platform).

@IlyaBizyaev
Copy link
Author

The download page is here: http://mingw-w64.org/doku.php/download
If I remember it right, you need the "Mingw-build" one for 4.9.2.

@noloader
Copy link
Collaborator

Thanks Ilya.

Something looks very fishy here... MinGW does not recognize the project. And it appears different individuals have administrative control, and the projects are based in different countries. At minimum, I would expect email addresses to be consistent. I.e., both use _mingw-users-owner@lists.sourceforge.net_ because its MinGW. And I definetly don't trust these garbage addresses: _b6wnwyoptcoe5n6efws9@e.o-w-o.info_.

$ whois mingw-w64.org | grep Registrant
Registrant ID:ovh555cd417awjj
Registrant Name:Adrien Nader
Registrant Organization:
Registrant Street: mingw-w64.org, office #8303039
Registrant Street: c/o OwO, BP80157
Registrant City:Roubaix Cedex 1
Registrant State/Province:
Registrant Postal Code:59053
Registrant Country:FR
Registrant Phone:+33.899498765
Registrant Phone Ext:
Registrant Fax:
Registrant Fax Ext:
Registrant Email:b6wnwyoptcoe5n6efws9@e.o-w-o.info

$ whois mingw.org | grep Registrant
Registrant ID:fed46a4501b17109
Registrant Name:Mumit  Khan
Registrant Organization:Mumit Khan
Registrant Street: 520 N. Pinckney St., Suite 1
Registrant City:Madison
Registrant State/Province:WI
Registrant Postal Code:53703
Registrant Country:US
Registrant Phone:+1.6082588241
Registrant Phone Ext:
Registrant Fax: +1.6082588241
Registrant Fax Ext:
Registrant Email:mingw-users-owner@lists.sourceforge.net

@IlyaBizyaev
Copy link
Author

Yes, MinGW-w64 is a fork, but a popular one. It seems to me that lots of former MinGW project participants moved there.

@IlyaBizyaev
Copy link
Author

Just read more on the main page: http://mingw-w64.org/doku.php/start

@IlyaBizyaev
Copy link
Author

Here is their mailing list: mingw-w64-public@lists.sourceforge.net

@noloader
Copy link
Collaborator

Thanks again.

I followed the link you provided, then followed to downloads. It took me to http://mingw-w64.org/doku.php/download. In the download matrix, I tried to download MinGW builds (http://mingw-w64.org/doku.php/download/mingw-builds), Win-Builds (http://mingw-w64.org/doku.php/download/win-builds) and Msys2 (http://mingw-w64.org/doku.php/download/msys2). None of them appear to provide a MinGW64 download. It looks like they sent me to empty wiki pages.

Where, exactly, is there download in that table?

Or, can you test RC6 at https://sourceforge.net/projects/cryptopp/files/cryptopp/5.6.3/ ?

Or, can you provide me with remote access to one of your machines that has it installed?

@Zireael-N
Copy link
Contributor

Msys2 (http://mingw-w64.org/doku.php/download/msys2). None of them appear to provide a MinGW64 download. It looks like they sent me to empty wiki pages.

Assuming you installed Msys2, you need to do the following on the first launch:

5. Update the system packages with
pacman --needed -Sy bash pacman pacman-mirrors msys2-runtime
6. Close MSYS2, run it again from Start menu and update the rest with
pacman -Su

Then you can install mingw-w64-i686-gcc and mingw-w64-x86_64-gcc with pacman -S <package>. Don't forget to install make as well.

Msys2 provides 3 shortcuts: "MSYS2 Shell", "MinGW-w64 Win32 Shell" and "MinGW-w64 Win64 Shell", you need to use the 2nd to compile 32-bit binaries and the 3rd to compile 64-bit binaries.

@Zireael-N
Copy link
Contributor

This happens because MinGW-w64 has its own implementation of memcpy_s, yet doesn't have these defined: _MEMORY_S_DEFINED and __STDC_WANT_SECURE_LIB__.

You can fix this by replacing:

#if (!__STDC_WANT_SECURE_LIB__ && !defined(_MEMORY_S_DEFINED))

with:

#if (!__STDC_WANT_SECURE_LIB__ && !defined(_MEMORY_S_DEFINED) && !defined(__MINGW64__))

in misc.h.

@IlyaBizyaev
Copy link
Author

Sorry, I cannot remember the exact download.
It seems to me that I've used the official MinGW-w64 Installer for that purpose. You can find it here: http://sourceforge.net/projects/mingw-w64/
Here is my full gcc -v output:

Using built-in specs.
COLLECT_GCC=c:\MinGW-w64\mingw64\bin\gcc.exe
COLLECT_LTO_WRAPPER=c:/MinGW-w64/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/4
.9.2/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../../../src/gcc-4.9.2/configure --host=x86_64-w64-mingw32 --bu
ild=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --prefix=/mingw64 --with-sysr
oot=/c/mingw492/x86_64-492-win32-seh-rt_v4-rev3/mingw64 --with-gxx-include-dir=/
mingw64/x86_64-w64-mingw32/include/c++ --enable-shared --enable-static --disable
-multilib --enable-languages=ada,c,c++,fortran,objc,obj-c++,lto --enable-libstdc
xx-time=yes --enable-threads=win32 --enable-libgomp --enable-libatomic --enable-
lto --enable-graphite --enable-checking=release --enable-fully-dynamic-string --
enable-version-specific-runtime-libs --disable-isl-version-check --disable-cloog
-version-check --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-bootst
rap --disable-rpath --disable-win32-registry --disable-nls --disable-werror --di
sable-symvers --with-gnu-as --with-gnu-ld --with-arch=nocona --with-tune=core2 -
-with-libiconv --with-system-zlib --with-gmp=/c/mingw492/prerequisites/x86_64-w6
4-mingw32-static --with-mpfr=/c/mingw492/prerequisites/x86_64-w64-mingw32-static
 --with-mpc=/c/mingw492/prerequisites/x86_64-w64-mingw32-static --with-isl=/c/mi
ngw492/prerequisites/x86_64-w64-mingw32-static --with-cloog=/c/mingw492/prerequi
sites/x86_64-w64-mingw32-static --enable-cloog-backend=isl --with-pkgversion='x8
6_64-win32-seh-rev3, Built by MinGW-W64 project' --with-bugurl=http://sourceforg
e.net/projects/mingw-w64 CFLAGS='-O2 -pipe -I/c/mingw492/x86_64-492-win32-seh-rt
_v4-rev3/mingw64/opt/include -I/c/mingw492/prerequisites/x86_64-zlib-static/incl
ude -I/c/mingw492/prerequisites/x86_64-w64-mingw32-static/include' CXXFLAGS='-O2
 -pipe -I/c/mingw492/x86_64-492-win32-seh-rt_v4-rev3/mingw64/opt/include -I/c/mi
ngw492/prerequisites/x86_64-zlib-static/include -I/c/mingw492/prerequisites/x86_
64-w64-mingw32-static/include' CPPFLAGS= LDFLAGS='-pipe -L/c/mingw492/x86_64-492
-win32-seh-rt_v4-rev3/mingw64/opt/lib -L/c/mingw492/prerequisites/x86_64-zlib-st
atic/lib -L/c/mingw492/prerequisites/x86_64-w64-mingw32-static/lib '
Thread model: win32
gcc version 4.9.2 (x86_64-win32-seh-rev3, Built by MinGW-W64 project)

By the way, @Zireael-N, I simply use MSYS that comes with MinGW-32.

@Zireael-N
Copy link
Contributor

By the way, @Zireael-N, I simply use MSYS that comes with MinGW-32.

The Msys2 part was addressed to Jeffrey. Have you tried doing what I suggested here?
Here's the exact line:

cryptopp/misc.h

Line 212 in 1d5bcc0

#if (!__STDC_WANT_SECURE_LIB__ && !defined(_MEMORY_S_DEFINED))
.

@noloader
Copy link
Collaborator

noloader commented Nov 5, 2015

@IlyaBizyaev, @Zireael-N - I have more bad news.... I tried to install MinGW and MinGW-64 on two different machines - Windows 7 and Windows 8. Only one of them ever worked for me (MinGW/Windows 7); the other three never worked.

Now the WIndows 7/MinGW machine is broken:

$ cd cryptopp
$ ./cryptest.sh
sh: ./cryptest.sh: /bin/bash: bad interpreter: No such file or directory

The same tests ran fine yesterday. I've tried reinstalling MinGW, but that did not help.

MinGW and MinGW-64 don't seem to have the stability we expect or need (or at least for me under the role of tester). MinGW and MinGW-64 cause me more problems than Debian Unstable :) I'm going to remove MinGW and MinGW-64 from my testing regime. It causes too many problems (and a lot of frustration), and the time can be better spent elsewhere (for me).

We talked about similar on the Crypto++ mailing list recently; see Strategy for Accommodating Unstable Platforms and Tools. Consensus was we should make an effort, but not waste too much time on platforms like these. Group consensus is important because it gives me authority to act. Without consensus, I have no authority and I cannot act.

Don't read too much into it. I only said "... remove MinGW and MinGW-64 from my testing regime" because my time is better spent elsewhere. I did not say we should drop support altogether.

Would either of you guys pick up the torch and take responsibility for this platform?


Would either of you guys pick up the torch and take responsibility for this platform?

I should probably qualify this now... Sadly, this is not in a vaccuum. MinGW and MinGW-64 changes could affect down level MinGW versions, Windows and Cygwin. So testing should include something for those platforms, too.

I can test the changes under the older platforms, like Windows XP, Windows Vista, Visual Studio 2005 and Visual Studio 2008.

@noloader
Copy link
Collaborator

noloader commented Nov 5, 2015

@Zireael-N, @IlyaBizyaev, @Liberus

Change:
#if (!STDC_WANT_SECURE_LIB && !defined(_MEMORY_S_DEFINED))
with:
#if (!STDC_WANT_SECURE_LIB && !defined(_MEMORY_S_DEFINED) && !defined(MINGW64))

I believe the library provides memcpy_s and memmove_s for platforms like Linux. I believe the Windows-compatibles are supposed to use Microsoft's implementation.

I think the change is consistent with what's supposed to happen. Does anyone see any problems with it?

If there are no objections, then can someone test it and perform a merge request?

@Zireael-N
Copy link
Contributor

sh: ./cryptest.sh: /bin/bash: bad interpreter: No such file or directory

I don't understand whether it says it can't find /bin/bash or ./cryptest.sh.

But the repository certainly doesn't have the script:
2015-11-05_07-39-35

I'm experiencing this when trying to build tests:

g++ -o cryptest.exe -DNDEBUG -g2 -O3 -fPIC -march=native -Wall -Wextra -Wno-type-limits -Wno-unknown-pragmas -pipe bench.o bench2.o test.o validat0.o validat1.o validat2.o validat3.o adhoc.o datatest.o regtest.o fipsalgt.o dlltest.o ./libcryptopp.a  -lws2_32
./libcryptopp.a(winpipes.o): In function `ZN8CryptoPP19WindowsPipeReceiver16GetReceiveResultEv':
C:\GitHub\cryptopp/winpipes.cpp:131: undefined reference to `non-virtual thunk to CryptoPP::WindowsPipeSource::GetHandle() const'
C:\GitHub\cryptopp/winpipes.cpp:131: undefined reference to `non-virtual thunk to CryptoPP::WindowsPipeSource::GetHandle() const'
./libcryptopp.a(winpipes.o): In function `ZN8CryptoPP19WindowsPipeReceiver7ReceiveEPhj':
C:\GitHub\cryptopp/winpipes.cpp:94: undefined reference to `non-virtual thunk to CryptoPP::WindowsPipeSource::GetHandle() const'
C:\GitHub\cryptopp/winpipes.cpp:94: undefined reference to `non-virtual thunk to CryptoPP::WindowsPipeSource::GetHandle() const'
collect2.exe: error: ld returned 1 exit status

Was getting warning: -fPIC ignored for target (all code is position independent) as well for every file.

I'll try different compilation options to see if it can be fixed.

And about __MINGW64__, it doesn't seem to be defined if you use i686 toolchain, to build a 32-bit version. Though it still uses the same library that does have memcpy_s implemented.

There's a diff in default defines between MinGW and MinGW-w64 with i686 toolchain. The ones that are worth looking at:

+#define __SIZEOF_FLOAT80__ 12
+#define __SIZEOF_FLOAT128__ 16
+#define __STDC_UTF_16__ 1
+#define __STDC_UTF_32__ 1
+#define __STDC_VERSION__ 201112L
+#define __GNUC_STDC_INLINE__ 1
-#define __GNUC_GNU_INLINE__ 1

And the whole list: https://gist.github.com/Zireael-N/15240b72b30796b5184f

@Zireael-N
Copy link
Contributor

Okay, that error had nothing to do with compilation options:

Notice how WindowsPipeReceiver inherits virtual HANDLE GetHandle() const =0 but doesn't define it:

class WindowsPipeReceiver : public WindowsPipe, public NetworkReceiver

See https://github.com/Zireael-N/cryptopp/commit/f9bf7190cc4821b0d35e6c230ee35008f80e4ea2 ; if it's a correct guess as to what it's supposed to do, I'll make a pull request.


Edit: I found the script on Crypto++'s Wiki. Takes an eternity to run. :(

The results are:

Testing started: Thu,  5 Nov, 2015 08:39:17
Testing finished: Thu,  5 Nov, 2015 09:49:04

19 configurations tested

18 errors detected

15 of them are g++ -shared -o libcryptopp.so ... failing with undefined reference to '_imp__send@16'. Can be easily fixed by appending -lws2_32. For example:

g++ -shared -o libcryptopp.so -DDEBUG -g2 -O2 -fPIC -march=native -Wall -Wextra -Wno-type-limits -Wno-unknown-pragmas -pipe shacal2.o seed.o shark.o zinflate.o gf2n.o socketft.o oaep.o rc2.o default.o wait.o wake.o twofish.o safer.o iterhash.o adler32.o marss.o blowfish.o ecp.o strciphr.o dh2.o ida.o zlib.o elgamal.o algparam.o tea.o rijndael.o eax.o network.o sha.o emsa2.o pkcspad.o squaretb.o idea.o authenc.o hmac.o zdeflate.o xtrcrypt.o simple.o mars.o rc5.o fipstest.o queue.o hrtimer.o vmac.o eprecomp.o winpipes.o polynomi.o dsa.o gzip.o dessp.o files.o base32.o sharkbox.o randpool.o esign.o hex.o sosemanuk.o arc4.o osrng.o skipjack.o gcm.o integer.o xtr.o fips140.o cpu.o filters.o bfinit.o rabin.o gf2_32.o 3way.o rdtables.o rsa.o cbcmac.o tftables.o gost.o md5.o nbtheory.o panama.o sha3.o modes.o casts.o algebra.o cryptlib.o gfpcrypt.o dll.o ec2n.o blumshub.o des.o basecode.o base64.o rc6.o gf256.o mqueue.o misc.o pssr.o channels.o rng.o tiger.o cast.o rw.o square.o asn.o whrlpool.o md4.o dh.o ccm.o md2.o mqv.o tigertab.o crc.o ttmac.o luc.o seal.o salsa.o trdlocal.o pubkey.o camellia.o ripemd.o eccrypto.o serpent.o cmac.o -lws2_32

3 of them are:

g++ -DNDEBUG -g2 -O2 -DCRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY  -fPIC -march=native -Wall -Wextra -Wno-type-limits -Wno-unknown-pragmas -pipe -c elgamal.cpp
elgamal.cpp:1:0: warning: -fPIC ignored for target (all code is position independent)
 // elgamal.cpp - written and placed in the public domain by Wei Dai
 ^
In file included from elgamal.h:7:0,
                 from elgamal.cpp:4:
dsa.h:26:34: error: 'MIN_PRIME_LENGTH' is not a member of 'CryptoPP::DSA {aka CryptoPP::DSA2<CryptoPP::SHA1>}'
 const int MIN_DSA_PRIME_LENGTH = DSA::MIN_PRIME_LENGTH;
                                  ^
dsa.h:27:34: error: 'MAX_PRIME_LENGTH' is not a member of 'CryptoPP::DSA {aka CryptoPP::DSA2<CryptoPP::SHA1>}'
 const int MAX_DSA_PRIME_LENGTH = DSA::MAX_PRIME_LENGTH;
                                  ^
dsa.h:28:39: error: 'PRIME_LENGTH_MULTIPLE' is not a member of 'CryptoPP::DSA {aka CryptoPP::DSA2<CryptoPP::SHA1>}'
 const int DSA_PRIME_LENGTH_MULTIPLE = DSA::PRIME_LENGTH_MULTIPLE;
                                       ^
In file included from elgamal.h:7:0,
                 from elgamal.cpp:4:
dsa.h: In function 'bool CryptoPP::GenerateDSAPrimes(const byte*, size_t, int&, CryptoPP::Integer&, unsigned int, CryptoPP::Integer&)':
dsa.h:31:10: error: 'GeneratePrimes' is not a member of 'CryptoPP::DSA {aka CryptoPP::DSA2<CryptoPP::SHA1>}'
  {return DSA::GeneratePrimes(seed, seedLength, counter, p, primeLength, q);}
          ^
GNUmakefile:529: recipe for target 'elgamal.o' failed

Another edit: I see that you've updated the repo with RC6, now I'm getting this:

rdrand.cpp:435:5: error: #error "Please report on the Crypto++ user group"
 #   error "Please report on the Crypto++ user group"
     ^
GNUmakefile:449: recipe for target 'rdrand.o' failed

@IlyaBizyaev
Copy link
Author

Hello, @noloader !
Frankly speaking, I'm not good at troubleshooting, but I'll do my best to help you with that installation problems.
As for the MinGW-32, I used the official installer that can be found here.
On installation, I also choose MSYS.
Don't then forget to specify the path to C:\MinGW\bin folder in your PATH environmental variable.
I also usually run this mingwvars.bat script from the C:\MinGW folder, don't know if it helps:

@echo.
@echo Setting up environment for using MinGW with GCC from %~dp0.
@set PATH=%~dp0bin;%PATH%

As for your script, I don't quite understand it.

  1. Do you run it from MSYS or from cmd.exe?
  2. Why do you use the cd cryptopp command? In my case, cryptopp is located in the root of C: drive, and I use cd /c/cryptopp
  3. Finally, does this file really exists? If yes, try explicit sh ./cryptest.sh or bash ./cryptest.sh call. Try to launch other commands like cat, vim etc.

As for your suggestion to take responsibility on the platform, I can only say that if I could fix it myself, I wouldn't have asked for solution here 😉 That's not the area I'm good at (at least for now).

And finally, which alternatives to MinGW would you suggest?

@IlyaBizyaev
Copy link
Author

The fixed, proposed by @Zireael-N, works fine, and both libcryptopp and cryptest.exe compile fine under MinGW-w64 (no matter if unalign data access is allowed or not) 😄 .
However, tests still fail when CRYPTOPP_NO_UNALIGNED_DATA_ACCESS is defined.
I'll propose a PR.

@IlyaBizyaev
Copy link
Author

What's interesting is that the Crypto++ that I clone with Git and the one I download in archive from GitHub differ really much!
Here is how this line looks in misc.h from the Git repository:

// ************** misc functions ***************

#if (!__STDC_WANT_SECURE_LIB__ && !defined(_MEMORY_S_DEFINED)) && !(defined(__MINGW__) || defined(__MINGW32__))

//! \brief Bounds checking replacement for \p memcpy
//! \param dest pointer to the desination memory block
//! \param sizeInBytes the size of the desination memory block, in bytes
//! \param src pointer to the source memory block
//! \param count the size of the source memory block, in bytes
//! \throws InvalidArgument
//! \details ISO/IEC TR-24772 provides bounds checking interfaces for potentially unsafe functions like \p memcpy, \p strcpy and \p memmove. However, not all standard libraries provides them, like Glibc. The library's \p memcpy_s is a near-drop in replacement. Its only a near-replacement because the library's version throws an \p InvalidArgument on a bounds violation.
//! \note \p memcpy_s will \p assert the pointers \p src and \p dest are not \p NULL in debug builds. Passing \p NULL for either pointer is undefined behavior.

And that's how the one from *.zip looks:

// ************** misc functions ***************

#if (!__STDC_WANT_SECURE_LIB__ && !defined(_MEMORY_S_DEFINED)
inline void memcpy_s(void *dest, size_t sizeInBytes, const void *src, size_t count)
{
    // NULL pointers to memcpy is undefined behavior
    CRYPTOPP_ASSERT(dest); CRYPTOPP_ASSERT(src);

    if (count > sizeInBytes)
        throw InvalidArgument("memcpy_s: buffer overflow");

    memcpy(dest, src, count);
}

@noloader
Copy link
Collaborator

noloader commented Nov 5, 2015

What's interesting is that the Crypto++ that I clone with Git and the one I download in archive from GitHub differ really much!

Hmmm.... I'm not sure what GitHub is providing as a ZIP. You should probably abandon it if it does not pass the sniff test.

The ZIP download from the website is OK. You can find it at http://www.cryptopp.com/cryptopp563rc6.zip . I verified http://www.cryptopp.com/cryptopp563rc6.zip provides the changes.

Can you switch to the clone and verify the issues still exist (or no longer exist) with the latest check-in?

Or, can you verify the issues still exist (or no longer exist) with cryptopp563rc6.zip?

@noloader
Copy link
Collaborator

noloader commented Nov 5, 2015

@Zireael-N,@IlyaBizyaev

I found the script on Crypto++'s Wiki. Takes an eternity to run. :(

Oh man... Try a Debian Chroot. it takes 6 to 12 hours to verify a change set on, say, S/390 or ARMHF.

15 of them are g++ -shared -o libcryptopp.so ... failing with undefined reference to '_imp__send@16'. Can be easily fixed by appending -lws2_32....

This was because GNUmakefile did not include LDLIBS for the libcryptopp.so recipe. It never included it. See, for example, GNUMakefile for Crypto++ 5.6.2.

The only thing that really changed is we are now testing it. I believe the fix has been checked in.

@noloader
Copy link
Collaborator

noloader commented Nov 5, 2015

and both libcryptopp and cryptest.exe compile fine under MinGW-w64 (no matter if unalign data access is allowed or not).

However, tests still fail when CRYPTOPP_NO_UNALIGNED_DATA_ACCESS is defined.

OK, we will need more details. "no matter if unalign data access is allowed or not..." - that's controlled by CRYPTOPP_NO_UNALIGNED_DATA_ACCESS:

$ grep -n CRYPTOPP_NO_UNALIGNED_DATA_ACCESS *.h *.cpp
config.h:37:#ifndef CRYPTOPP_NO_UNALIGNED_DATA_ACCESS
config.h:38:// # define CRYPTOPP_NO_UNALIGNED_DATA_ACCESS
config.h:459:#if !defined(CRYPTOPP_NO_UNALIGNED_DATA_ACCESS) && !defined(CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS)

And then:

$ awk 'NR >= 459 && NR <= 464' config.h
#if !defined(CRYPTOPP_NO_UNALIGNED_DATA_ACCESS) && !defined(CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS)
#if (CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || defined(__powerpc__) || (__ARM_FEATURE_UNALIGNED >= 1))
    #define CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS
#endif
#endif

I'm not sure how it can work one way but not another because everything pivots on CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS:

$ grep CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS *.h *.cpp | wc -l
      31

@IlyaBizyaev
Copy link
Author

The build now looks completely different! That seems to be a GitHub issue...
Both aligned and unaligned versions build fine and pass all tests on MinGW-w64.
MinGW-32 still experiences problems:

g++ -DNDEBUG -g2 -O2 -march=native -pipe -c cryptlib.cpp
In file included from cryptlib.cpp:19:0:
misc.h: In function 'void CryptoPP::IncrementCounterByOne(byte*, const byte*, un
signed int)':
misc.h:744:35: error: 'memcpy_s' was not declared in this scope
  memcpy_s(output, size, input, i+1);
                                   ^
In file included from filters.h:15:0,
                 from cryptlib.cpp:20:
secblock.h: In instantiation of 'void CryptoPP::SecBlock<T, A>::Assign(const T*,
 CryptoPP::SecBlock<T, A>::size_type) [with T = unsigned char; A = CryptoPP::All
ocatorWithCleanup<unsigned char>; CryptoPP::SecBlock<T, A>::size_type = unsigned
 int]':
algparam.h:49:29:   required from here
secblock.h:532:57: error: 'memcpy_s' was not declared in this scope
    {memcpy_s(m_ptr, m_size*sizeof(T), ptr, len*sizeof(T));}
                                                         ^
secblock.h: In instantiation of 'typename A::pointer CryptoPP::StandardReallocat
e(A&, T*, typename A::size_type, typename A::size_type, bool) [with T = unsigned
 char; A = CryptoPP::AllocatorWithCleanup<unsigned char>; typename A::pointer =
unsigned char*; typename A::size_type = unsigned int]':
secblock.h:220:70:   required from 'CryptoPP::AllocatorWithCleanup<T, T_Align16>
::pointer CryptoPP::AllocatorWithCleanup<T, T_Align16>::reallocate(T*, CryptoPP:
:AllocatorWithCleanup<T, T_Align16>::size_type, CryptoPP::AllocatorWithCleanup<T
, T_Align16>::size_type, bool) [with T = unsigned char; bool T_Align16 = false;
CryptoPP::AllocatorWithCleanup<T, T_Align16>::pointer = unsigned char*; CryptoPP
::AllocatorWithCleanup<T, T_Align16>::size_type = unsigned int]'
secblock.h:629:9:   required from 'void CryptoPP::SecBlock<T, A>::New(CryptoPP::
SecBlock<T, A>::size_type) [with T = unsigned char; A = CryptoPP::AllocatorWithC
leanup<unsigned char>; CryptoPP::SecBlock<T, A>::size_type = unsigned int]'
filters.h:79:30:   required from here
secblock.h:127:77: error: 'memcpy_s' was not declared in this scope
   if (oldPtr && newPointer) {memcpy_s(newPointer, copySize, oldPtr, copySize);}

                                                                             ^
secblock.h: In instantiation of 'CryptoPP::SecBlock<T, A>::SecBlock(const Crypto
PP::SecBlock<T, A>&) [with T = unsigned char; A = CryptoPP::AllocatorWithCleanup
<unsigned char>]':
algparam.h:29:7:   required from 'CryptoPP::AlgorithmParametersTemplate<T>::Algo
rithmParametersTemplate(const char*, const T&, bool) [with T = CryptoPP::ConstBy
teArrayParameter]'
algparam.h:424:104:   required from 'CryptoPP::AlgorithmParameters& CryptoPP::Al
gorithmParameters::operator()(const char*, const T&, bool) [with T = CryptoPP::C
onstByteArrayParameter]'
algparam.h:462:58:   required from 'CryptoPP::AlgorithmParameters CryptoPP::Make
Parameters(const char*, const T&, bool) [with T = CryptoPP::ConstByteArrayParame
ter]'
filters.h:695:81:   required from here
secblock.h:443:79: error: 'memcpy_s' was not declared in this scope
    if (t.m_ptr) {memcpy_s(m_ptr, m_size*sizeof(T), t.m_ptr, t.m_size*sizeof(T))
;}
                                                                               ^

@noloader
Copy link
Collaborator

noloader commented Nov 5, 2015

MinGW-32 still experiences problems:

Would you post the output of the following commands? They will dump the preprocessor symbols. Provide them for both MinGW-32 and MinGW-64. Make them available for download somewhere. Or ZIP them and email them to me and Zireael.

# Under MinGW-32
g++ -x c++ -dM -march=native -E - < /dev/null | sort | uniq > mingw-32.txt

# Under MinGW-64
g++ -x c++ -dM -march=native -E - < /dev/null | sort | uniq > mingw-64.txt

This uses the compiler driver to tell us what it is defining. It will invoke cplusplus1, which is the C++ preprocessor.

The MinGW-32 issue is being tracked under Issue 58: Rollup of errata items to be fixed before release.

@Zireael-N
Copy link
Contributor

This uses the compiler driver to tell us what it is defining.

Check the end of this message.

@noloader
Copy link
Collaborator

noloader commented Nov 5, 2015

Check the end of this message.

Too much noise in the diff. There's no need for diff tell me there's a different between SIZE_MAX or SIZE_T_MAX on X86 and X64.

Add a cut -d " " -f 2 to pull out the defines.

I am also interested in some of the usual suspects, like __MINGW__, __i386__, __x86_64__ and __LP64__.

@Zireael-N
Copy link
Contributor

I'm not entirely sure where I need to add cut. But here are all the defines:

  1. https://gist.github.com/Zireael-N/b78d94f758e4b41580e0
  2. https://gist.github.com/Zireael-N/3bbe6c650c4e7d2c04ad

Too much noise in the diff

That's why I mentioned the ones that actually do matter before giving a link to the full list.

X86 and X64

I was actually comparing MinGW-w64 with a 32-bit toolchain vs MinGW. It's a bit confusing but the former can compile both 32 and 64-bit binaries while the latter can only compile 32-bit binaries.

That's why checking for __MINGW64__ was not an ideal solution: the former only defines it when you compile a 64-bit binary.

The former does have memcpy_s implemented no matter what the architecture is, the latter doesn't have it implemented.

@noloader
Copy link
Collaborator

noloader commented Nov 6, 2015

@IlyaBizyaev, @Zireael-N,

Yeah, that did the job.

      #if defined(__MINGW32__)
        using CryptoPP::memcpy_s;
      #endif

before:

      memcpy_s(&w, sizeof(w), "\x01\x02\x03\x04", 4);

Perfect. Let's wait to hear back from Ilya.

If all goes well, then I'll close it. Hallelujah.

@Zireael-N
Copy link
Contributor

Excuse me if I'm wrong, but that fixes just the test executable, and not the library itself. Maybe this code should be used in misc.h?

Not really. The test executable's code is within CryptoPP namespace. Thus, it sees both CryptoPP::memcpy_s and the library's memcpy_s when using MinGW-w64.

This shouldn't be a problem to you unless you use using namespace CryptoPP AND use memcpy_s AND use MinGW-w64 that has its own implementation of the function.

@noloader
Copy link
Collaborator

noloader commented Nov 6, 2015

... but that fixes just the test executable, and not the library itself.

Like Neo said: the problem is choice. Also see What is the logic behind the “using” keyword in C++? on Stack Overflow.

@IlyaBizyaev
Copy link
Author

OK. The only question left is how should I check this solution.
The initial issue was caused by a GitHub archive downloading problem (it archived obsolete sources, git clone solved this).
The Crypto++ is built successfully under MinGW-w64 and passes all tests.
Problems are:

  1. MinGW-32 fails to build Crypto++ (see the output earlier).
  2. Compilation errors occur when building applications (MGW64, 64 bit)
    Both are connected with memcpy_s().
    Will both problems be solved after that fix?

@Zireael-N
Copy link
Contributor

@IlyaBizyaev

Will both problems be solved after that fix?

Yes, I can use make validat1.o with both compilers.

And if I remove #error that stops compilation because of #60, I can compile the whole library with both compilers.

@IlyaBizyaev
Copy link
Author

OK, that's great! Let me compile it and see.

@noloader
Copy link
Collaborator

noloader commented Nov 6, 2015

  1. MinGW-32 fails to build Crypto++ (see the output earlier).

This probably needs a new bug report if its a new issue.

  1. Compilation errors occur when building applications (MGW64, 64 bit)
    Both are connected with memcpy_s().
    Will both problems be solved after that fix?

You might want to perform a make clean or make distclean to ensure past artifacts don't munge things up.

@noloader
Copy link
Collaborator

noloader commented Nov 6, 2015

@IlyaBizyaev, @Zireael-N,

For completeness, this code:

00133         word32 w;
00134         memcpy_s(&w, sizeof(w), "\x01\x02\x03\x04", 4);

Was present going back to at least Crypto++ 5.6.1.

@noloader
Copy link
Collaborator

noloader commented Nov 6, 2015

@IlyaBizyaev, @Zireael-N,

So I'm clear... Is this your change?

bool TestSettings()
{
    // https://github.com/weidai11/cryptopp/issues/28
#if defined(__MINGW__)
    using CryptoPP::memcpy_s;
#endif

    bool pass = true;
    cout << "\nTesting Settings...\n\n";

    word32 w;
    memcpy_s(&w, sizeof(w), "\x01\x02\x03\x04", 4);
    ...
}

@Zireael-N
Copy link
Contributor

It's MINGW32. MINGW is not defined.

@IlyaBizyaev
Copy link
Author

No, @Zireael-N , @noloader... That doesn't work. Here is the full build log:

$ cd /c/cryptopp/
$ make
WARNING: CRYPTOPP_INIT_PRIORITY is not defined in config.h.
WARNING: CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 is defined in config.h.
WARNING: You should make these changes in config.h, and not CXXFLAGS.
WARNING: You can 'mv config.recommend config.h', but it breaks versioning.
WARNING: See http://cryptopp.com/wiki/config.h for more details.

g++ -DNDEBUG -g2 -O2 -march=native -pipe -c cryptlib.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c cpu.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c 3way.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c adler32.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c algebra.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c algparam.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c arc4.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c asn.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c authenc.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c base32.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c base64.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c basecode.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c bfinit.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c blowfish.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c blumshub.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c camellia.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c cast.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c casts.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c cbcmac.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c ccm.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c channels.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c cmac.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c crc.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c default.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c des.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c dessp.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c dh.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c dh2.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c dll.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c dsa.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c eax.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c ec2n.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c eccrypto.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c ecp.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c elgamal.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c emsa2.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c eprecomp.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c esign.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c files.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c filters.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c fips140.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c fipstest.cpp
fipstest.cpp:15:0: warning: "_WIN32_WINNT" redefined
 #define _WIN32_WINNT 0x0400
 ^
In file included from c:/MinGW-w64/mingw64/x86_64-w64-mingw32/include/crtdefs.h:10:0,
                 from c:/MinGW-w64/mingw64/x86_64-w64-mingw32/include/wchar.h:9,

                 from c:/MinGW-w64/mingw64/x86_64-w64-mingw32/include/c++/cwchar:44,
                 from c:/MinGW-w64/mingw64/x86_64-w64-mingw32/include/c++/bits/postypes.h:40,
                 from c:/MinGW-w64/mingw64/x86_64-w64-mingw32/include/c++/bits/char_traits.h:40,
                 from c:/MinGW-w64/mingw64/x86_64-w64-mingw32/include/c++/string:40,
                 from stdcpp.h:9,
                 from cryptlib.h:84,
                 from seckey.h:9,
                 from rijndael.h:7,
                 from aes.h:9,
                 from dll.h:11,
                 from fipstest.cpp:8:
c:/MinGW-w64/mingw64/x86_64-w64-mingw32/include/_mingw.h:225:0: note: this is the location of the previous definition
 #define _WIN32_WINNT 0x502
 ^
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c gcm.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c gf256.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c gf2_32.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c gf2n.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c gfpcrypt.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c gost.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c gzip.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c hex.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c hmac.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c hrtimer.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c ida.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c idea.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c integer.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c iterhash.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c luc.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c mars.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c marss.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c md2.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c md4.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c md5.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c misc.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c modes.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c mqueue.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c mqv.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c nbtheory.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c network.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c oaep.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c osrng.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c panama.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c pkcspad.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c polynomi.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c pssr.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c pubkey.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c queue.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c rabin.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c randpool.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c rc2.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c rc5.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c rc6.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c rdrand.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c rdtables.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c rijndael.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c ripemd.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c rng.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c rsa.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c rw.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c safer.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c salsa.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c seal.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c seed.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c serpent.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c sha.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c sha3.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c shacal2.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c shark.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c sharkbox.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c skipjack.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c socketft.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c sosemanuk.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c square.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c squaretb.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c strciphr.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c tea.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c tftables.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c tiger.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c tigertab.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c trdlocal.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c ttmac.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c twofish.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c vmac.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c wait.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c wake.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c whrlpool.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c xtr.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c xtrcrypt.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c zdeflate.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c zinflate.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c zlib.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c winpipes.cpp
ar r libcryptopp.a cryptlib.o cpu.o 3way.o adler32.o algebra.o algparam.o arc4.o
 asn.o authenc.o base32.o base64.o basecode.o bfinit.o blowfish.o blumshub.o cam
ellia.o cast.o casts.o cbcmac.o ccm.o channels.o cmac.o crc.o default.o des.o de
ssp.o dh.o dh2.o dll.o dsa.o eax.o ec2n.o eccrypto.o ecp.o elgamal.o emsa2.o epr
ecomp.o esign.o files.o filters.o fips140.o fipstest.o gcm.o gf256.o gf2_32.o gf
2n.o gfpcrypt.o gost.o gzip.o hex.o hmac.o hrtimer.o ida.o idea.o integer.o iter
hash.o luc.o mars.o marss.o md2.o md4.o md5.o misc.o modes.o mqueue.o mqv.o nbth
eory.o network.o oaep.o osrng.o panama.o pkcspad.o polynomi.o pssr.o pubkey.o qu
eue.o rabin.o randpool.o rc2.o rc5.o rc6.o rdrand.o rdtables.o rijndael.o ripemd
.o rng.o rsa.o rw.o safer.o salsa.o seal.o seed.o serpent.o sha.o sha3.o shacal2
.o shark.o sharkbox.o skipjack.o socketft.o sosemanuk.o square.o squaretb.o strc
iphr.o tea.o tftables.o tiger.o tigertab.o trdlocal.o ttmac.o twofish.o vmac.o w
ait.o wake.o whrlpool.o xtr.o xtrcrypt.o zdeflate.o zinflate.o zlib.o winpipes.o

c:\MinGW-w64\mingw64\bin\ar.exe: creating libcryptopp.a
ranlib libcryptopp.a
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c bench.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c bench2.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c test.cpp
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c validat1.cpp
validat1.cpp: In function 'bool TestSettings()':
validat1.cpp:154:22: error: 'CryptoPP::memcpy_s' has not been declared
      using CryptoPP::memcpy_s;
                      ^
make: *** [validat1.o] Error 1

Diffs:

diff --git a/config.h b/config.h
index 9728ee2..bd66ad1 100644
--- a/config.h
+++ b/config.h
@@ -35,7 +35,7 @@
 // Define this to ensure C/C++ standard compliance and respect for GCC aliasing rules and other alignment fodder. If you
 // experience a break with GCC at -O3, you should try this first. Guard it in case its set on the command line (and it differs).
 #ifndef CRYPTOPP_NO_UNALIGNED_DATA_ACCESS
-// # define CRYPTOPP_NO_UNALIGNED_DATA_ACCESS
+# define CRYPTOPP_NO_UNALIGNED_DATA_ACCESS
 #endif

 // ***************** Less Important Settings ***************
diff --git a/validat1.cpp b/validat1.cpp
index 478199f..4fccb50 100644
--- a/validat1.cpp
+++ b/validat1.cpp
@@ -150,6 +150,9 @@ bool TestSettings()
    cout << "\nTesting Settings...\n\n";

    word32 w;
+   #if defined(__MINGW32__)
+       using CryptoPP::memcpy_s;
+   #endif
    memcpy_s(&w, sizeof(w), "\x01\x02\x03\x04", 4);

    if (w == 0x04030201L)

g++ -dumpmachine: x86_64-w64-mingw32
gcc --vesrion:

gcc --version:
gcc.exe (x86_64-win32-seh-rev3, Built by MinGW-W64 project) 4.9.2
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

@IlyaBizyaev
Copy link
Author

MinGW-32 doesn't build it either.

WARNING: CRYPTOPP_INIT_PRIORITY is not defined in config.h.
WARNING: CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 is defined in config.h.
WARNING: You should make these changes in config.h, and not CXXFLAGS.
WARNING: You can 'mv config.recommend config.h', but it breaks versioning.
WARNING: See http://cryptopp.com/wiki/config.h for more details.

g++ -DNDEBUG -g2 -O2 -march=native -pipe -c cryptlib.cpp
In file included from cryptlib.cpp:19:0:
misc.h: In function 'void CryptoPP::IncrementCounterByOne(byte*, const byte*, un
signed int)':
misc.h:744:35: error: 'memcpy_s' was not declared in this scope
  memcpy_s(output, size, input, i+1);
                                   ^
In file included from filters.h:15:0,
                 from cryptlib.cpp:20:
secblock.h: In instantiation of 'void CryptoPP::SecBlock<T, A>::Assign(const T*,
 CryptoPP::SecBlock<T, A>::size_type) [with T = unsigned char; A = CryptoPP::All
ocatorWithCleanup<unsigned char>; CryptoPP::SecBlock<T, A>::size_type = unsigned int]':
algparam.h:49:29:   required from here
secblock.h:532:57: error: 'memcpy_s' was not declared in this scope
    {memcpy_s(m_ptr, m_size*sizeof(T), ptr, len*sizeof(T));}
                                                         ^
secblock.h: In instantiation of 'typename A::pointer CryptoPP::StandardReallocate(A&, T*, typename A::size_type, typename A::size_type, bool) [with T = unsigned char; A = CryptoPP::AllocatorWithCleanup<unsigned char>; typename A::pointer =
unsigned char*; typename A::size_type = unsigned int]':
secblock.h:220:70:   required from 'CryptoPP::AllocatorWithCleanup<T, T_Align16>::pointer CryptoPP::AllocatorWithCleanup<T, T_Align16>::reallocate(T*, CryptoPP::AllocatorWithCleanup<T, T_Align16>::size_type, CryptoPP::AllocatorWithCleanup<T, T_Align16>::size_type, bool) [with T = unsigned char; bool T_Align16 = false;
CryptoPP::AllocatorWithCleanup<T, T_Align16>::pointer = unsigned char*; CryptoPP::AllocatorWithCleanup<T, T_Align16>::size_type = unsigned int]'
secblock.h:629:9:   required from 'void CryptoPP::SecBlock<T, A>::New(CryptoPP::
SecBlock<T, A>::size_type) [with T = unsigned char; A = CryptoPP::AllocatorWithCleanup<unsigned char>; CryptoPP::SecBlock<T, A>::size_type = unsigned int]'
filters.h:79:30:   required from here
secblock.h:127:77: error: 'memcpy_s' was not declared in this scope
   if (oldPtr && newPointer) {memcpy_s(newPointer, copySize, oldPtr, copySize);}

                                                                             ^
secblock.h: In instantiation of 'CryptoPP::SecBlock<T, A>::SecBlock(const Crypto
PP::SecBlock<T, A>&) [with T = unsigned char; A = CryptoPP::AllocatorWithCleanup<unsigned char>]':
algparam.h:29:7:   required from 'CryptoPP::AlgorithmParametersTemplate<T>::Algo
rithmParametersTemplate(const char*, const T&, bool) [with T = CryptoPP::ConstByteArrayParameter]'
algparam.h:424:104:   required from 'CryptoPP::AlgorithmParameters& CryptoPP::Al
gorithmParameters::operator()(const char*, const T&, bool) [with T = CryptoPP::ConstByteArrayParameter]'
algparam.h:462:58:   required from 'CryptoPP::AlgorithmParameters CryptoPP::Make
Parameters(const char*, const T&, bool) [with T = CryptoPP::ConstByteArrayParameter]'
filters.h:695:81:   required from here
secblock.h:443:79: error: 'memcpy_s' was not declared in this scope
    if (t.m_ptr) {memcpy_s(m_ptr, m_size*sizeof(T), t.m_ptr, t.m_size*sizeof(T))
;}
                                                                               ^

make: *** [cryptlib.o] Error 1

@Zireael-N
Copy link
Contributor

Of course it doesn't work! You forgot to remove !(defined(__MINGW__) || defined(__MINGW32__)) from misc.h.

Change:

#if (!__STDC_WANT_SECURE_LIB__ && !defined(_MEMORY_S_DEFINED)) && !(defined(__MINGW__) || defined(__MINGW32__))

to:

#if (!__STDC_WANT_SECURE_LIB__ && !defined(_MEMORY_S_DEFINED))

@noloader
Copy link
Collaborator

noloader commented Nov 6, 2015

Of course it doesn't work!

Ah, good catch... I was staring at it scratching my head....

@noloader
Copy link
Collaborator

noloader commented Nov 6, 2015

@IlyaBizyaev - Did Zireael's observation clear the issue for you?

@IlyaBizyaev
Copy link
Author

There are good news and a bad one.
Good ones:

  1. All MinGW builds are fine and pass tests! 😃
  2. That errors don't occur any more! 😄
    But there's a bad one: still can't compile the app (MGW-64, static linkage) - some references are undefined.
obj\Release\EntangleExtras.o:EntangleExtras.cpp:(.text+0x90): undefined reference to `vtable for CryptoPP::RandomPool'
obj\Release\EntangleExtras.o:EntangleExtras.cpp:(.text$_ZN8CryptoPP20AutoSeededRandomPoolD1Ev[__ZN8CryptoPP20AutoSeededRandomPoolD1Ev]+0x9): undefined reference to `vtable for CryptoPP::RandomPool'
obj\Release\EntangleExtras.o:EntangleExtras.cpp:(.text$_ZN8CryptoPP20AutoSeededRandomPoolD0Ev[__ZN8CryptoPP20AutoSeededRandomPoolD0Ev]+0x9): undefined reference to `vtable for CryptoPP::RandomPool'
obj\Release\EntangleExtras.o:EntangleExtras.cpp:(.text$_ZN8CryptoPP10RandomPoolD2Ev[__ZN8CryptoPP10RandomPoolD2Ev]+0x9): undefined reference to `vtable for CryptoPP::RandomPool'
obj\Release\EntangleExtras.o:EntangleExtras.cpp:(.text.startup+0x43): undefined reference to `CryptoPP::RandomPool::RandomPool()'
obj\Release\EntangleExtras.o:EntangleExtras.cpp:(.text.startup+0x66): undefined reference to `CryptoPP::AutoSeededRandomPool::Reseed(bool, unsigned int)'
obj\Release\EntangleExtras.o:EntangleExtras.cpp:(.rdata$_ZTVN8CryptoPP4SinkE[__ZTVN8CryptoPP4SinkE]+0x28): undefined reference to `CryptoPP::BufferedTransformation::GetMaxWaitObjectCount() const'
obj\Release\EntangleExtras.o:EntangleExtras.cpp:(.rdata$_ZTVN8CryptoPP4SinkE[__ZTVN8CryptoPP4SinkE]+0x2c): undefined reference to `CryptoPP::BufferedTransformation::GetWaitObjects(CryptoPP::WaitObjectContainer&, CryptoPP::CallStack const&)'
obj\Release\EntangleExtras.o:EntangleExtras.cpp:(.rdata$_ZTVN8CryptoPP4SinkE[__ZTVN8CryptoPP4SinkE]+0x3c): undefined reference to `CryptoPP::BufferedTransformation::Initialize(CryptoPP::NameValuePairs const&, int)'
obj\Release\EntangleExtras.o:EntangleExtras.cpp:(.rdata$_ZTVN8CryptoPP4SinkE[__ZTVN8CryptoPP4SinkE]+0x40): undefined reference to `CryptoPP::BufferedTransformation::Flush(bool, int, bool)'
obj\Release\EntangleExtras.o:EntangleExtras.cpp:(.rdata$_ZTVN8CryptoPP4SinkE[__ZTVN8CryptoPP4SinkE]+0x44): undefined reference to `CryptoPP::BufferedTransformation::MessageSeriesEnd(int, bool)'
obj\Release\EntangleExtras.o:EntangleExtras.cpp:(.rdata$_ZTVN8CryptoPP4SinkE[__ZTVN8CryptoPP4SinkE]+0x50): undefined reference to `CryptoPP::BufferedTransformation::MaxRetrievable() const'
obj\Release\EntangleExtras.o:EntangleExtras.cpp:(.rdata$_ZTVN8CryptoPP4SinkE[__ZTVN8CryptoPP4SinkE]+0x54): undefined reference to `CryptoPP::BufferedTransformation::AnyRetrievable() const'
obj\Release\EntangleExtras.o:EntangleExtras.cpp:(.rdata$_ZTVN8CryptoPP4SinkE[__ZTVN8CryptoPP4SinkE]+0x58): undefined reference to `CryptoPP::BufferedTransformation::Get(unsigned char&)'
obj\Release\EntangleExtras.o:EntangleExtras.cpp:(.rdata$_ZTVN8CryptoPP4SinkE[__ZTVN8CryptoPP4SinkE]+0x5c): undefined reference to `CryptoPP::BufferedTransformation::Get(unsigned char*, unsigned int)'
obj\Release\EntangleExtras.o:EntangleExtras.cpp:(.rdata$_ZTVN8CryptoPP4SinkE[__ZTVN8CryptoPP4SinkE]+0x60): undefined reference to `CryptoPP::BufferedTransformation::Peek(unsigned char&) const'
obj\Release\EntangleExtras.o:EntangleExtras.cpp:(.rdata$_ZTVN8CryptoPP4SinkE[__ZTVN8CryptoPP4SinkE]+0x64): undefined reference to `CryptoPP::BufferedTransformation::Peek(unsigned char*, unsigned int) const'
obj\Release\EntangleExtras.o:EntangleExtras.cpp:(.rdata$_ZTVN8CryptoPP4SinkE[__ZTVN8CryptoPP4SinkE]+0x68): undefined reference to `CryptoPP::BufferedTransformation::Skip(unsigned long long)'
obj\Release\EntangleExtras.o:EntangleExtras.cpp:(.rdata$_ZTVN8CryptoPP4SinkE[__ZTVN8CryptoPP4SinkE]+0x6c): undefined reference to `CryptoPP::BufferedTransformation::TotalBytesRetrievable() const'
obj\Release\EntangleExtras.o:EntangleExtras.cpp:(.rdata$_ZTVN8CryptoPP4SinkE[__ZTVN8CryptoPP4SinkE]+0x70): undefined reference to `CryptoPP::BufferedTransformation::NumberOfMessages() const'
obj\Release\EntangleExtras.o:EntangleExtras.cpp:(.rdata$_ZTVN8CryptoPP4SinkE[__ZTVN8CryptoPP4SinkE]+0x74): undefined reference to `CryptoPP::BufferedTransformation::AnyMessages() const'
obj\Release\EntangleExtras.o:EntangleExtras.cpp:(.rdata$_ZTVN8CryptoPP4SinkE[__ZTVN8CryptoPP4SinkE]+0x78): undefined reference to `CryptoPP::BufferedTransformation::GetNextMessage()'
obj\Release\EntangleExtras.o:EntangleExtras.cpp:(.rdata$_ZTVN8CryptoPP4SinkE[__ZTVN8CryptoPP4SinkE]+0x7c): undefined reference to `CryptoPP::BufferedTransformation::SkipMessages(unsigned int)'
obj\Release\EntangleExtras.o:EntangleExtras.cpp:(.rdata$_ZTVN8CryptoPP4SinkE[__ZTVN8CryptoPP4SinkE]+0x80): undefined reference to `CryptoPP::BufferedTransformation::SkipAll()'
obj\Release\EntangleExtras.o:EntangleExtras.cpp:(.rdata$_ZTVN8CryptoPP4SinkE[__ZTVN8CryptoPP4SinkE]+0x98): undefined reference to `CryptoPP::BufferedTransformation::ChannelCreatePutSpace(std::string const&, unsigned int&)'
obj\Release\EntangleExtras.o:EntangleExtras.cpp:(.rdata$_ZTVN8CryptoPP4SinkE[__ZTVN8CryptoPP4SinkE]+0x9c): undefined reference to `CryptoPP::BufferedTransformation::ChannelPut2(std::string const&, unsigned char const*, unsigned int, int, bool)'
obj\Release\EntangleExtras.o:EntangleExtras.cpp:(.rdata$_ZTVN8CryptoPP4SinkE[__ZTVN8CryptoPP4SinkE]+0xa0): undefined reference to `CryptoPP::BufferedTransformation::ChannelPutModifiable2(std::string const&, unsigned char*, unsigned int, int, bool)'
obj\Release\EntangleExtras.o:EntangleExtras.cpp:(.rdata$_ZTVN8CryptoPP4SinkE[__ZTVN8CryptoPP4SinkE]+0xa4): undefined reference to `CryptoPP::BufferedTransformation::ChannelFlush(std::string const&, bool, int, bool)'
obj\Release\EntangleExtras.o:EntangleExtras.cpp:(.rdata$_ZTVN8CryptoPP4SinkE[__ZTVN8CryptoPP4SinkE]+0xa8): undefined reference to `CryptoPP::BufferedTransformation::ChannelMessageSeriesEnd(std::string const&, int, bool)'
obj\Release\EntangleExtras.o:EntangleExtras.cpp:(.rdata$_ZTVN8CryptoPP4SinkE[__ZTVN8CryptoPP4SinkE]+0xac): undefined reference to `CryptoPP::BufferedTransformation::SetRetrievalChannel(std::string const&)'
obj\Release\EntangleExtras.o:EntangleExtras.cpp:(.rdata$_ZTVN8CryptoPP4SinkE[__ZTVN8CryptoPP4SinkE]+0xc0): undefined reference to `CryptoPP::BufferedTransformation::Attach(CryptoPP::BufferedTransformation*)'
obj\Release\EntangleExtras.o:EntangleExtras.cpp:(.rdata$_ZTVN8CryptoPP4SinkE[__ZTVN8CryptoPP4SinkE]+0xd4): undefined reference to `non-virtual thunk to CryptoPP::BufferedTransformation::GetMaxWaitObjectCount() const'
obj\Release\EntangleExtras.o:EntangleExtras.cpp:(.rdata$_ZTVN8CryptoPP4SinkE[__ZTVN8CryptoPP4SinkE]+0xd8): undefined reference to `non-virtual thunk to CryptoPP::BufferedTransformation::GetWaitObjects(CryptoPP::WaitObjectContainer&, CryptoPP::CallStack const&)'
obj\Release\EntangleExtras.o:EntangleExtras.cpp:(.rdata$_ZTVN8CryptoPP10BufferlessINS_4SinkEEE[__ZTVN8CryptoPP10BufferlessINS_4SinkEEE]+0x28): undefined reference to `CryptoPP::BufferedTransformation::GetMaxWaitObjectCount() const'
obj\Release\EntangleExtras.o:EntangleExtras.cpp:(.rdata$_ZTVN8CryptoPP10BufferlessINS_4SinkEEE[__ZTVN8CryptoPP10BufferlessINS_4SinkEEE]+0x2c): undefined reference to `CryptoPP::BufferedTransformation::GetWaitObjects(CryptoPP::WaitObjectContainer&, CryptoPP::CallStack const&)'
obj\Release\EntangleExtras.o:EntangleExtras.cpp:(.rdata$_ZTVN8CryptoPP10BufferlessINS_4SinkEEE[__ZTVN8CryptoPP10BufferlessINS_4SinkEEE]+0x3c): undefined reference to `CryptoPP::BufferedTransformation::Initialize(CryptoPP::NameValuePairs const&, int)'
obj\Release\EntangleExtras.o:EntangleExtras.cpp:(.rdata$_ZTVN8CryptoPP10BufferlessINS_4SinkEEE[__ZTVN8CryptoPP10BufferlessINS_4SinkEEE]+0x40): undefined reference to `CryptoPP::BufferedTransformation::Flush(bool, int, bool)'
obj\Release\EntangleExtras.o:EntangleExtras.cpp:(.rdata$_ZTVN8CryptoPP10BufferlessINS_4SinkEEE[__ZTVN8CryptoPP10BufferlessINS_4SinkEEE]+0x44): undefined reference to `CryptoPP::BufferedTransformation::MessageSeriesEnd(int, bool)'
obj\Release\EntangleExtras.o:EntangleExtras.cpp:(.rdata$_ZTVN8CryptoPP10BufferlessINS_4SinkEEE[__ZTVN8CryptoPP10BufferlessINS_4SinkEEE]+0x50): undefined reference to `CryptoPP::BufferedTransformation::MaxRetrievable() const'
obj\Release\EntangleExtras.o:EntangleExtras.cpp:(.rdata$_ZTVN8CryptoPP10BufferlessINS_4SinkEEE[__ZTVN8CryptoPP10BufferlessINS_4SinkEEE]+0x54): undefined reference to `CryptoPP::BufferedTransformation::AnyRetrievable() const'
obj\Release\EntangleExtras.o:EntangleExtras.cpp:(.rdata$_ZTVN8CryptoPP10BufferlessINS_4SinkEEE[__ZTVN8CryptoPP10BufferlessINS_4SinkEEE]+0x58): undefined reference to `CryptoPP::BufferedTransformation::Get(unsigned char&)'
obj\Release\EntangleExtras.o:EntangleExtras.cpp:(.rdata$_ZTVN8CryptoPP10BufferlessINS_4SinkEEE[__ZTVN8CryptoPP10BufferlessINS_4SinkEEE]+0x5c): undefined reference to `CryptoPP::BufferedTransformation::Get(unsigned char*, unsigned int)'
obj\Release\EntangleExtras.o:EntangleExtras.cpp:(.rdata$_ZTVN8CryptoPP10BufferlessINS_4SinkEEE[__ZTVN8CryptoPP10BufferlessINS_4SinkEEE]+0x60): undefined reference to `CryptoPP::BufferedTransformation::Peek(unsigned char&) const'
obj\Release\EntangleExtras.o:EntangleExtras.cpp:(.rdata$_ZTVN8CryptoPP10BufferlessINS_4SinkEEE[__ZTVN8CryptoPP10BufferlessINS_4SinkEEE]+0x64): undefined reference to `CryptoPP::BufferedTransformation::Peek(unsigned char*, unsigned int) const'
obj\Release\EntangleExtras.o:EntangleExtras.cpp:(.rdata$_ZTVN8CryptoPP10BufferlessINS_4SinkEEE[__ZTVN8CryptoPP10BufferlessINS_4SinkEEE]+0x68): undefined reference to `CryptoPP::BufferedTransformation::Skip(unsigned long long)'
obj\Release\EntangleExtras.o:EntangleExtras.cpp:(.rdata$_ZTVN8CryptoPP10BufferlessINS_4SinkEEE[__ZTVN8CryptoPP10BufferlessINS_4SinkEEE]+0x6c): undefined reference to `CryptoPP::BufferedTransformation::TotalBytesRetrievable() const'
obj\Release\EntangleExtras.o:EntangleExtras.cpp:(.rdata$_ZTVN8CryptoPP10BufferlessINS_4SinkEEE[__ZTVN8CryptoPP10BufferlessINS_4SinkEEE]+0x70): undefined reference to `CryptoPP::BufferedTransformation::NumberOfMessages() const'
obj\Release\EntangleExtras.o:EntangleExtras.cpp:(.rdata$_ZTVN8CryptoPP10BufferlessINS_4SinkEEE[__ZTVN8CryptoPP10BufferlessINS_4SinkEEE]+0x74): undefined reference to `CryptoPP::BufferedTransformation::AnyMessages() const'
obj\Release\EntangleExtras.o:EntangleExtras.cpp:(.rdata$_ZTVN8CryptoPP10BufferlessINS_4SinkEEE[__ZTVN8CryptoPP10BufferlessINS_4SinkEEE]+0x78): undefined reference to `CryptoPP::BufferedTransformation::GetNextMessage()'
obj\Release\EntangleExtras.o:EntangleExtras.cpp:(.rdata$_ZTVN8CryptoPP10BufferlessINS_4SinkEEE[__ZTVN8CryptoPP10BufferlessINS_4SinkEEE]+0x7c): undefined reference to `CryptoPP::BufferedTransformation::SkipMessages(unsigned int)'

And on MGW32, all symbols are OK, but... remember that annoying issue with m_allocated? So, here it is...

@IlyaBizyaev
Copy link
Author

But I think those are different issues. What about pushing the changes and closing this issue?

@IlyaBizyaev
Copy link
Author

I've used make distclean.

@noloader
Copy link
Collaborator

noloader commented Nov 6, 2015

I've used make distclean...

You can use nm on randpool.o to ensure the symbols are present.
If you don't have a randpool.o, then you are not compiling randpool.cpp.

Here is randpool.h, and here is randpool.cpp. Nothing depends on __MINGW__ and friends.

@noloader
Copy link
Collaborator

noloader commented Nov 6, 2015

Closing...

@whitebarin
Copy link

Hello! I'm get last version from git. When compile (Qt 5.5.1 (mingw492_32)) there is next error
file: validat1.cpp CryptoPP::memcpy_s has not been declared.
When i change to (coment // using CryptoPP::memcpy_s;) ALL COMPILED OK!! ALL TESTES PASSED!!

my changes in file: validat1.cpp is
//#if defined(MINGW32)
// using CryptoPP::memcpy_s;
//#endif

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

No branches or pull requests

6 participants