CLion和Crypto ++库

凯西

不久前,我开始在Visual Studio 2015中对应用程序进行编码,设置所有库依赖项都没有问题。

现在,我决定搬到CLion。但是,我的应用程序具有cryptopp的依赖关系,需要在CLion项目中进行链接。

目前,我面临大量undefined reference错误

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'
[..]

我的确在CMakeLists中设置了包含目录:

set(EXTERN_LIBS E:/dev/libs)

include_directories(${EXTERN_LIBS} ${EXTERN_LIBS}/include)
link_directories(${EXTERN_LIBS})

但是,我仍然无法使其正常工作。

我正在为我的项目使用MinGW。这是设置和版本的预览:

在此处输入图片说明

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

w

我认为我们可能已经在Commit e4cef84883b2上清除了MinGW / C ++ 11问题你应该从主工作或执行git pull,然后取消对定义CRYPTOPP_NO_CXX11config.h:65(左右):

// 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 ++错误可以解决。

这是我们在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_INITCRYPTOPP_CXX11_SYNCHRONIZATION,和CRYPTOPP_CXX11_ATOMICS


第二个问题,与Clion和Cmake有关,解决如下。我们使用Autotools和Cmake文件设置一个单独的GitHub。Autotools文件位于cryptopp-autotools,Cmake文件位于cryptopp-cmake

仓库位于我的GiHub中,因为这是编写库并提供Crypto ++ GitHub的Wei Dai宁愿避免的那种管理方式。逻辑分离还有助于建立逻辑边界,因此人们知道Autotools和CMake不属于官方Crypto ++发行版。

社区负责Autotools和Cmake,我们将在问题上与社区合作。如果社区投入工作,那么Autotools和Cmake将会得到改善。如果Autotools或CMake都稳定了,那么我们将在文件中添加一个tarball到官方发行版。

当前,Autotools和Cmake处于需要改进的状态。Cmake的问题在CMake中有详细介绍。Wiki上的当前状态Autotools的问题并未真正记录下来,因为我与发行版维护人员合作。有点像我们知道问题是什么,但其他大多数人却不知道。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章