3

I am trying to build cryptopp 5.6.1 with mingw 4.8.1 (sjlj). I've changed GNUMakefile from Crypto++ & MinGW

But there are several issue:

  • I've compile error if I try to build it as shared library;
  • On my machine it works (intel i5 (2nd generation) with Windows 7 ) but on Windows Xp on an Intel atom D2500 an error occured (no entry point for memmove_s in msvcrt.dll )

When I try to build as shared library I've the following error:

make dll
make: *** No rule to make target 'cryptopp.dll', needed by 'cryptest.import.exe'. Stop.
make libcryptopp.dll
// ...
g++ -std=c++11 -DNDEBUG -O3 -m32 -msse2 -msse3 -mssse3 -DCRYPTOPP_EXPORTS -c hex.cpp -o hex.export.o
g++ -std=c++11 -DNDEBUG -O3 -m32 -msse2 -msse3 -mssse3 -DCRYPTOPP_EXPORTS -c hmac.cpp -o hmac.export.o
g++ -std=c++11 -DNDEBUG -O3 -m32 -msse2 -msse3 -mssse3 -DCRYPTOPP_EXPORTS -c integer.cpp -o integer.export.o
g++ -std=c++11 -DNDEBUG -O3 -m32 -msse2 -msse3 -mssse3 -DCRYPTOPP_EXPORTS -c iterhash.cpp -o iterhash.export.o
g++ -std=c++11 -DNDEBUG -O3 -m32 -msse2 -msse3 -mssse3 -DCRYPTOPP_EXPORTS -c misc.cpp -o misc.export.o
g++ -std=c++11 -DNDEBUG -O3 -m32 -msse2 -msse3 -mssse3 -DCRYPTOPP_EXPORTS -c modes.cpp -o modes.export.o
make: *** No rule to make target 'modexppc.export.o', needed by 'libcryptopp.dll'.  Stop.

Does someone has compiled succeful crypto++ with mingw 4.8.1? This is the snippet of my makefile:

CXXFLAGS = -std=c++11 -DNDEBUG -O3 -m32 -msse2 -msse3 -mssse3
ARFLAGS = rc
LDLIBS += -lws2_32
LDFLAGS =
MKDIR = mkdir
CP = copy

SRCS = $(wildcard *.cpp)

OBJS = $(SRCS:.cpp=.o)
# test.o needs to be after bench.o for cygwin 1.1.4 (possible ld bug?)
TESTOBJS = bench.o bench2.o test.o validat1.o validat2.o validat3.o adhoc.o datatest.o regtest.o fipsalgt.o dlltest.o
LIBOBJS = $(filter-out $(TESTOBJS),$(OBJS))

DLLSRCS = algebra.cpp algparam.cpp asn.cpp basecode.cpp cbcmac.cpp channels.cpp cryptlib.cpp des.cpp dessp.cpp dh.cpp dll.cpp dsa.cpp ec2n.cpp eccrypto.cpp ecp.cpp eprecomp.cpp files.cpp filters.cpp fips140.cpp fipstest.cpp gf2n.cpp gfpcrypt.cpp hex.cpp hmac.cpp integer.cpp iterhash.cpp misc.cpp modes.cpp modexppc.cpp mqueue.cpp nbtheory.cpp oaep.cpp osrng.cpp pch.cpp pkcspad.cpp pubkey.cpp queue.cpp randpool.cpp rdtables.cpp rijndael.cpp rng.cpp rsa.cpp sha.cpp simple.cpp skipjack.cpp strciphr.cpp trdlocal.cpp
DLLOBJS = $(DLLSRCS:.cpp=.export.o)
LIBIMPORTOBJS = $(LIBOBJS:.o=.import.o)
TESTIMPORTOBJS = $(TESTOBJS:.o=.import.o)
DLLTESTOBJS = dlltest.dllonly.o

lib: libcryptopp.a

all: cryptest.exe

test: cryptest.exe
    cryptest.exe v

install: lib
    $(CP) *.h include\cryptopp
    $(CP) *.a lib

clean:
    del cryptest.exe libcryptopp.a $(LIBOBJS) $(TESTOBJS) cryptopp.dll libcryptopp.dll.a libcryptopp.import.a cryptest.import.exe dlltest.exe $(DLLOBJS) $(LIBIMPORTOBJS) $(TESTIMPORTOBJS) $(DLLTESTOBJS)

libcryptopp.a: $(LIBOBJS)
    $(AR) $(ARFLAGS) $@ $(LIBOBJS)

libcryptopp.so: $(LIBOBJS)
    $(CXX) -shared -o $@ $(LIBOBJS)

cryptest.exe: libcryptopp.a $(TESTOBJS)
    $(CXX) -o $@ $(CXXFLAGS) $(TESTOBJS) -L. -lcryptopp $(LDFLAGS) $(LDLIBS)

nolib: $(OBJS)      # makes it faster to test changes
    $(CXX) -o ct $(CXXFLAGS) $(OBJS) $(LDFLAGS) $(LDLIBS)

dll: cryptest.import.exe dlltest.exe

libcryptopp.dll: $(DLLOBJS)
    $(CXX) -shared -o $@ $(CXXFLAGS) $(DLLOBJS) $(LDFLAGS) $(LDLIBS) -Wl,--out-implib=libcryptopp.dll.a

libcryptopp.import.a: $(LIBIMPORTOBJS)
    $(AR) $(ARFLAGS) $@ $(LIBIMPORTOBJS)
    $(RANLIB) $@

cryptest.import.exe: cryptopp.dll libcryptopp.import.a $(TESTIMPORTOBJS)
    $(CXX) -o $@ $(CXXFLAGS) $(TESTIMPORTOBJS) -L. -lcryptopp.dll -lcryptopp.import $(LDFLAGS) $(LDLIBS)

dlltest.exe: cryptopp.dll $(DLLTESTOBJS)
    $(CXX) -o $@ $(CXXFLAGS) $(DLLTESTOBJS) -L. -lcryptopp.dll $(LDFLAGS) $(LDLIBS)

%.dllonly.o : %.cpp
    $(CXX) $(CXXFLAGS) -DCRYPTOPP_DLL_ONLY -c $< -o $@

%.import.o : %.cpp
    $(CXX) $(CXXFLAGS) -DCRYPTOPP_IMPORTS -c $< -o $@

%.export.o : %.cpp
    $(CXX) $(CXXFLAGS) -DCRYPTOPP_EXPORTS -c $< -o $@

%.o : %.cpp
    $(CXX) $(CXXFLAGS) -c $<

Edit

To let it work I've forced the funcion memmove_s defined in misc.h (of cryptopp) to be defined inlined and now works also on windows xp (where memmove_s is not defined in msvcrt.dll).

Question: Can I change the mscvrt.dll of windows xp with one defined on Windows 7?

4

3 回答 3

4

构建它的一种方法是使用 qmake:

  • 我删除了 GNUMakefile,
  • qmake-项目
  • 我将 pro 文件打开到 QtCreator 中,更改TEMPLATElib并将 ws2_32 添加到 lib

pro 文件现在看起来像这样

TEMPLATE = lib
INCLUDEPATH += .
CONFIG -= qt
HEADERS += ...
SOURCES += ...

win32-g++ {
    QMAKE_CXXFLAGS += -msse -msse2 -msse3 -mssse3
    LIBS += -lws2_32
}

这似乎工作。

于 2013-08-09T12:11:16.537 回答
1

这是一个尝试

放入modexppc.cpp您的 CRYPTOPP 文件夹。

模块exppc.cpp

// modexppc.cpp - written and placed in the public domain by Wei Dai

#include "pch.h"

#ifndef CRYPTOPP_IMPORTS

#include "modexppc.h"
#include "asn.h"
NAMESPACE_BEGIN(CryptoPP)


NAMESPACE_END

#endif
于 2013-08-09T00:19:10.660 回答
1

我向MinGW 开发团队发送了一个修复 Windows XP 中 memmove_s的补丁。它已被接受,并将很快出现在较新的 MinGW 版本中。现在它应该可以在 CentOS 7 MinGW 发行版和 Fedora 21 MinGW 上使用。

Crypto++ 5.6.2 现在可以在 MinGW 上构建良好,无需修改,使用 make(并正确设置 CC、CXX 和 PATH 环境变量)。在使用 MinGW 4.9 IIRC 的 CentOS 7 上测试。

于 2014-08-02T10:47:52.217 回答