CLion和Crypto ++库 [英] CLion and Crypto++ library

查看:164
本文介绍了CLion和Crypto ++库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Some time ago I started coding my application in Visual Studio 2015, had no issues setting all of the library dependencies.

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

Now, I decided to move to CLion. However my application has a dependency of cryptopp library, which I need to link in my CLion project.

当前,我面临大量的undefined reference错误

Currently, I'm facing tons of undefined reference errors

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中设置了包含目录:

I have indeed set include directories in my CMakeLists:

set(EXTERN_LIBS E:/dev/libs)

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

但是,我仍然无法正常工作.

However, I still cannot get it to work.

我正在将MinGW用于我的项目.这是设置和版本的预览:

I'm using MinGW for my project. Here is a preview of settings and versions:

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

How can I properly add cryptopp library into my project in CLion?

推荐答案

我认为我们可能已经在CRYPTOPP_NO_CXX11的定义. ="nofollow noreferrer"> config.h:65 (或如此):

I think we may have mostly cleared the MinGW/C++11 issue at Commit e4cef84883b2. You should work from Master or perform a git pull, and then uncomment the define for CRYPTOPP_NO_CXX11 in config.h : 65 (or so):

// 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有关的问题,Windows缺乏适当的C ++ 11支持,但是您是间接获得它们.它们是间接的,因为MinGW和GCC位于顶层. MinGW和GCC可能无法提供C ++ 11,因为基础平台无法提供.

I think the problems is, you are hitting issues related to Windows and its lack of proper C++11 support, but you are getting them indirectly. They are indirect because MinGW and GCC is layered on top. MinGW and GCC cannot possibly provide C++11 because the underlying platform cannot.

我认为此时最好的选择是定义CRYPTOPP_NO_CXX11.我认为我们无法像在Windows上那样为您做到这一点,因为我们需要访问的定义隐藏在MinGW和GCC的后面.而且,我们还有一些MSVC ++错误可以解决.

I think your best bet at this point is to define CRYPTOPP_NO_CXX11. I don't believe we can do it for you like we do on Windows because the defines we need access to are hidden behind MinGW and GCC. And we also have some MSVC++ bugs to workaround.

这是我们在Windows上执行的操作,但是我们无法访问MinGW中的这些定义(来自config.h:950):

Here's how we do it on Windows, but we don't have access to these defines in MinGW (from 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_SYNCHRONIZATIONCRYPTOPP_CXX11_ATOMICS.

If you define CRYPTOPP_NO_CXX11, then the following will not be defined and you will avoid the problems: CRYPTOPP_CXX11_DYNAMIC_INIT, CRYPTOPP_CXX11_SYNCHRONIZATION, and CRYPTOPP_CXX11_ATOMICS.

第二个问题(与Clion和Cmake有关)按以下方式解决.我们使用Autotools和Cmake文件设置了单独的GitHub. Autotools文件位于 cryptopp-autotools ,而Cmake文件位于

The second issue, the one related to Clion and Cmake, was settled as follows. We setup a separate GitHub with our Autotools and Cmake files. The Autotools files are at cryptopp-autotools, and the Cmake files are at cryptopp-cmake.

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

The repositories are in my GiHub because this is the sort of administrivia that Wei Dai, who wrote the library and provides the Crypto++ GitHub, prefers to avoid. The logical separation also helps establish the logical boundary so folks know Autotools and CMake are not part of the official Crypto++ distribution.

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

The community is responsible for Autotools and Cmake, and we will work with the community on issues. If the community puts in the work, then Autotools and Cmake will improve. If either Autotools or CMake gets stable, then we will add a tarball with the files to the official distribution.

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

Currently Autotools and Cmake are in states that needs improvement. The problems with Cmake are detailed at CMake | Current Status on the wiki. The problems with Autotools are not really documented because I work with distro maintainers on them. Its kind of like we know what the prolems are, but most others do not.

这篇关于CLion和Crypto ++库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆