Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/125.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ CLion和Crypto++;图书馆_C++_Mingw_Static Libraries_Clion_Crypto++ - Fatal编程技术网

C++ CLion和Crypto++;图书馆

C++ CLion和Crypto++;图书馆,c++,mingw,static-libraries,clion,crypto++,C++,Mingw,Static Libraries,Clion,Crypto++,不久前,我开始在Visual Studio 2015中编写我的应用程序,在设置所有库依赖项时没有遇到任何问题 现在,我决定搬到克莱恩。但是,我的应用程序依赖于cryptopplibrary,我需要在CLion项目中链接它 目前,我面临着大量的未定义引用错误 undefined reference to `CryptoPP::Integer::Integer(char const*)' undefined reference to `CryptoPP::Integer::Integer(char

不久前,我开始在Visual Studio 2015中编写我的应用程序,在设置所有库依赖项时没有遇到任何问题

现在,我决定搬到克莱恩。但是,我的应用程序依赖于
cryptopp
library,我需要在CLion项目中链接它

目前,我面临着大量的
未定义引用
错误

undefined reference to `CryptoPP::Integer::Integer(char const*)'
undefined reference to `CryptoPP::Integer::Integer(char const*)'
undefined reference to `CryptoPP::Integer::Integer(char const*)'
undefined reference to `CryptoPP::DH_Domain<CryptoPP::DL_GroupParameters_GFP_DefaultSafePrime, CryptoPP::EnumToType<CryptoPP::CofactorMultiplicationOption, 0> >::AccessGroupParameters()'
undefined reference to `CryptoPP::DH_Domain<CryptoPP::DL_GroupParameters_GFP_DefaultSafePrime, CryptoPP::EnumToType<CryptoPP::CofactorMultiplicationOption, 0> >::GetGroupParameters() const'
undefined reference to `CryptoPP::DH_Domain<CryptoPP::DL_GroupParameters_GFP_DefaultSafePrime, CryptoPP::EnumToType<CryptoPP::CofactorMultiplicationOption, 0> >::GetGroupParameters() const'
[..]
然而,我仍然无法让它工作

我正在使用MinGW进行我的项目。以下是设置和版本的预览:


我如何才能将
cryptopp
库正确地添加到我在CLion中的项目中?

我想我们可能已经基本解决了MinGW/C++11的问题。您应该从Master开始工作,或者执行一个
git pull
,然后在(大约)中取消注释
CRYPTOPP\u NO\u cx11

我认为问题在于,您遇到了与Windows相关的问题以及它缺乏适当的C++11支持,但是您间接地得到了这些问题。它们是间接的,因为MinGW和GCC是分层的。MinGW和GCC不可能提供C++11,因为底层平台无法提供

我认为在这一点上,最好的办法是定义
CRYPTOPP\u NO\u CXX11
。我不相信我们可以像在Windows上那样为您这样做,因为我们需要访问的定义隐藏在MinGW和GCC后面。我们还需要解决一些MSVC++错误

下面是我们在Windows上的操作方式,但我们无法访问MinGW中的这些定义(从
config.h
:950):

如果您定义了
CRYPTOPP\u NO\u cx11
,则不会定义以下内容,您将避免出现问题:
CRYPTOPP\u cx11\u DYNAMIC\u INIT
CRYPTOPP\u cx11\u同步
,以及
CRYPTOPP\u cx11\u原子


第二个问题与Clion和Cmake有关,解决方法如下。我们使用Autotools和Cmake文件设置了一个单独的GitHub。自动工具文件位于,Cmake文件位于

存储库在我的GiHub中,因为这是编写库并提供Crypto++GitHub的魏岱喜欢避免的那种管理。逻辑分离还有助于建立逻辑边界,因此人们知道Autotools和CMake不是官方Crypto++发行版的一部分

社区负责Autotools和Cmake,我们将与社区合作解决这些问题。如果社区投入工作,那么Autotools和Cmake将得到改进。如果Autotools或CMake变得稳定,那么我们将在官方发行版中添加一个带有文件的tarball


目前,Autotools和Cmake处于需要改进的状态。有关Cmake的问题,请参见wiki上的。自动工具的问题并没有真正的记录下来,因为我与发行版维护人员一起工作。这有点像我们知道问题是什么,但大多数其他人不知道。

使用
link\u目录(${EXTERN\u LIBS})
只向搜索路径添加一个目录。实际上,您并没有告诉CMake链接任何库。为此,请使用命令。@Someprogrammerdude我已经试过了。使用
target\u link\u库(myapp cryptlib.lib)时出现
mingw32/bin/ld.exe:找不到-lcryptlib
错误。当我指定库的完整路径时,此错误消失,但是
未定义的引用
错误仍然存在。您的
cryptlib.lib
是用MS VC++构建的。您现在正在尝试将其与使用GCC(MinGW)编译的对象文件链接。那不行。GCC和VC++不兼容,尤其是不同的协议。因此,在您的目标代码中,由MIW发出的被破坏的C++标识符与VC++编译库导出的任何值不匹配,并且是未定义的引用。您需要使用MinGW从源代码构建
cryptopp
,以创建与ABI兼容的库。@MikeKinghan我可以使用Visual Studio编译器吗?我读过一些关于cryptopp的文章,结果发现它不支持CMake。真的吗?在Windows 10 Pro上使用mingw-w64 GCC 7.2.0构建软件包时,
CMakeLists.txt
正在运行,没有问题。当然,你可以用微软的VC++来构建它,很高兴我能帮助改进cmake的crypto++。回答得很好。
set(EXTERN_LIBS E:/dev/libs)

include_directories(${EXTERN_LIBS} ${EXTERN_LIBS}/include)
link_directories(${EXTERN_LIBS})
// 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
// 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