2017-05-09 26 views
0

我使用的MinGW 5.3.0加密++ 5.6.5:'互斥' 不在MinGW的5.3.0和 'STD' 的成员

C:\MinGW>g++ -std=c++11 -s -D_WIN32_WINNT=0x0501 LOG.cpp -U__STRICT_ANSI__ Decclass.cpp \ 
-IC:\\MinGW\\ -IC:\\MinGW\\boost -LC:\\MinGW -lssl -lcrypto -lcryptopp -lgdi32 -lPCRYPT \ 
-lz -ltiny -lwsock32 -lws2_32 -lShlwapi 

在下面的错误编译结果。

c:\mingw\cryptopp565\include\cryptopp\misc.h:287:14: error: 'mutex' in namespace 'std' 
does not name a typestatic std::mutex s_mutex; 

c:\mingw\cryptopp565\include\cryptopp\misc.h:296:18: error: 'mutex' is not a member of 
'std'std::lock_guard<std::mutex> lock(s_mutex); 

enter image description here

这显示'互斥' 不是 '性病'

我是否需要MinGW的花药版本中的一员? 或者我可以修复这个构建本身?

+4

请不要将文字作为图片发布,而改为发布文字。 – Jonas

+0

@Jonas谢谢... –

+2

你是否包含'互斥'? – taskinoor

回答

1

我修复编辑“misc.h”路径中的这个问题 “cryptopp565 \包括\ cryptopp \ misc.h”

misc.h我列入互斥顶部。 HPPBoost库

#include "c:\mingw\include\boost\asio\detail\mutex.hpp" 

,我改变了命名空间还从STD的boost :: ASIO: :详细

static std::mutex s_mutex; 
static boost::asio::detail::mutex s_mutex; 
+0

我建议您访问'config.h',并确保定义'CRYPTOPP_CXX11_SYNCHRONIZATION'没有为您的配置定义。 – jww

0

我想我们可能大多已被清除MinGW的/ C++ 11的问题在Commit e4cef84883b2。你应该从主工作或执行git pull,并取消在config.h : 65的定义CRYPTOPP_NO_CXX11(左右):

// Define CRYPTOPP_NO_CXX11 to avoid C++11 related features shown at the 
// end of this file. Some compilers and standard C++ headers advertise C++11 
// but they are really just C++03 with some additional C++11 headers and 
// non-conforming classes. You might also consider `-std=c++03` or 
// `-std=gnu++03`, but they are required options when building the library 
// and all programs. CRYPTOPP_NO_CXX11 is probably easier to manage but it may 
// cause -Wterminate warnings under GCC. MSVC++ has a similar warning. 
// Also see https://github.com/weidai11/cryptopp/issues/529 
// #define CRYPTOPP_NO_CXX11 1 

我认为问题是,你打与Windows和它缺乏适当的C问题++ 11支持,但是你正在间接获取它们。它们是间接的,因为MinGW和GCC位于顶层。 MinGW和GCC不可能提供C++ 11,因为底层平台不能。

我认为你最好的选择就是定义CRYPTOPP_NO_CXX11。我不认为我们可以像在Windows上那样为你做,因为我们需要访问的定义隐藏在MinGW和GCC后面。而且我们也有一些MSVC++的bug来解决问题。

下面是我们如何做到这一点在Windows上,但我们并没有获得在MinGW的这些定义(从config.h:950):

// Dynamic Initialization and Destruction with Concurrency ("Magic Statics") 
// MS at VS2015 with Vista (19.00); GCC at 4.3; LLVM Clang at 2.9; Apple Clang at 4.0; Intel 11.1; SunCC 5.13. 
// Microsoft's implementation only works for Vista and above, so its further 
// limited. http://connect.microsoft.com/VisualStudio/feedback/details/1789709 
#if (CRYPTOPP_MSC_VERSION >= 1900) && ((WINVER >= 0x0600) || (_WIN32_WINNT >= 0x0600)) || \ 
    (CRYPTOPP_LLVM_CLANG_VERSION >= 20900) || (CRYPTOPP_APPLE_CLANG_VERSION >= 40000) || \ 
    (__INTEL_COMPILER >= 1110) || (CRYPTOPP_GCC_VERSION >= 40300) || (__SUNPRO_CC >= 0x5130) 
# define CRYPTOPP_CXX11_DYNAMIC_INIT 1 
#endif // Dynamic Initialization compilers 

如果定义CRYPTOPP_NO_CXX11,那么下面将被定义并且您将避免这些问题:CRYPTOPP_CXX11_DYNAMIC_INIT,CRYPTOPP_CXX11_SYNCHRONIZATIONCRYPTOPP_CXX11_ATOMICS