C++ 如何在 Visual Studio 2010 中安装 Crypto++?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6619042/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 20:26:13  来源:igfitidea点击:

How do I install Crypto++ in Visual Studio 2010?

c++visual-studio-2010crypto++

提问by Christopher Peterson

I downloaded http://www.cryptopp.com/#download5.6.1 and have no clue that to do at this point. I am a total noob and need good instructions. thanks.

我下载了http://www.cryptopp.com/#download5.6.1 并且现在不知道该做什么。我是个菜鸟,需要很好的指导。谢谢。

回答by Nicholas

Directly from the readme (Which can be found here Crypto++ Svn Trunk):

直接从自述文件(可以在这里找到Crypto++ Svn Trunk):

* MSVC-Specific Information *

* MSVC 特定信息 *

On Windows, Crypto++ can be compiled into 3 forms: a static library including all algorithms, a DLL with only FIPS Approved algorithms, and a static library with only algorithms not in the DLL. (FIPS Approved means Approved according to the FIPS 140-2 standard.) The DLL may be used by itself, or it may be used together with the second form of the static library. MSVC project files are included to build all three forms, and sample applications using each of the three forms are also included.

在 Windows 上,Crypto++ 可以编译为 3 种形式:包含所有算法的静态库、仅包含 FIPS 批准算法的 DLL 和仅包含不在 DLL 中的算法的静态库。(FIPS Approved 是指根据 FIPS 140-2 标准批准。)DLL 可以单独使用,也可以与第二种形式的静态库一起使用。包括 MSVC 项目文件以构建所有三种形式,还包括使用这三种形式中的每一种的示例应用程序。

To compile Crypto++ with MSVC, open the "cryptest.dsw" (for MSVC 6 and MSVC .NET 2003) or "cryptest.sln" (for MSVC 2005 - 2010) workspace file and build one or more of the following projects:

要使用 MSVC 编译 Crypto++,请打开“cryptest.dsw”(对于 MSVC 6 和 MSVC .NET 2003)或“cryptest.sln”(对于 MSVC 2005 - 2010)工作区文件并构建以下一个或多个项目:

  • cryptopp - This builds the DLL. Please note that if you wish to use Crypto++ as a FIPS validated module, you must use a pre-built DLL that has undergone the FIPS validation process instead of building your own.
  • dlltest - This builds a sample application that only uses the DLL.
  • cryptest Non-DLL-Import Configuration - This builds the full static library along with a full test driver.
  • cryptest DLL-Import Configuration - This builds a static library containing only algorithms not in the DLL, along with a full test driver that uses both the DLL and the static library.
  • cryptopp - 这将构建 DLL。请注意,如果您希望使用 Crypto++ 作为 FIPS 验证模块,您必须使用经过 FIPS 验证过程的预构建 DLL,而不是构建您自己的。
  • dlltest - 这将构建一个仅使用 DLL 的示例应用程序。
  • cryptest 非 DLL 导入配置 - 这将构建完整的静态库以及完整的测试驱动程序。
  • cryptest DLL-Import Configuration - 这将构建一个静态库,该库仅包含不在 DLL 中的算法,以及一个使用 DLL 和静态库的完整测试驱动程序。

To use the Crypto++ DLL in your application, #include "dll.h" before including any other Crypto++ header files, and place the DLL in the same directory as your .exe file. dll.h includes the line #pragma comment(lib, "cryptopp") so you don't have to explicitly list the import library in your project settings.

要在您的应用程序中使用 Crypto++ DLL,请在包含任何其他 Crypto++ 头文件之前 #include "dll.h",并将 DLL 放在与 .exe 文件相同的目录中。dll.h 包含 #pragma comment(lib, "cryptopp") 行,因此您不必在项目设置中明确列出导入库。

To use a static library form of Crypto++, make the "cryptlib" project a dependency of your application project, or specify it as an additional library to link with in your project settings. In either case you should check the compiler options to make sure that the library and your application are using the same C++ run-time libraries and calling conventions.

要使用 Crypto++ 的静态库形式,请将“cryptlib”项目作为应用项目的依赖项,或将其指定为要在项目设置中链接的附加库。无论哪种情况,您都应该检查编译器选项以确保库和您的应用程序使用相同的 C++ 运行时库和调用约定。

If you have any questions feel free to ask and i'll update the anwser with my responses.

如果您有任何问题,请随时提出,我会用我的回答更新 anwser。

回答by jww

I downloaded http://www.cryptopp.com/#download5.6.1 and have no clue what to do at this point...

我下载了http://www.cryptopp.com/#download5.6.1 并且不知道此时该做什么......

This is a very late answer, but the project has released some new files to help folks use Visual Studio 2010 and above.

这是一个很晚的答案,但该项目发布了一些新文件来帮助人们使用 Visual Studio 2010 及更高版本。

The project had to release the updated files because VCUpgrade (provided with Visual Studio 2010) does a fairly poor job with this particular project. It has been a source of problems for a few years, and even visually impaired users were commenting about it. The problems were not fixed in VS2012, VS2013 and VS2015, so we don't believe Microsoft has any intentions of fixing the problems.

该项目不得不发布更新的文件,因为 VCUpgrade(随 Visual Studio 2010 提供)在这个特定项目中做得相当糟糕。几年来,它一直是问题的根源,甚至视障用户也对此发表评论。这些问题在 VS2012、VS2013 和 VS2015 中都没有修复,所以我们不认为微软有任何修复问题的意图。

To use the updated files, download the latest Crypto++ release from the website. Then, visit the Crypto++ wiki and fetch vs2010.zipfrom the page Visual Studio. Unzip vs2010.zipover the Crypto++ files. Finally double-click the file called cryptest.slnto have Visual Studio open the solution file.

要使用更新的文件,请从网站下载最新的 Crypto++ 版本。然后,访问 Crypto++ wiki 并vs2010.zip从页面Visual Studio 中获取。解压缩vs2010.zipCrypto++ 文件。最后双击调用的文件cryptest.sln,让 Visual Studio 打开解决方案文件。

The Crypto++ wikipage also offers project files that provide dynamic runtime linking for both VS2005 and VS2010.

加密+维基页面还提供项目提供动态运行时链接两个VS2005和VS2010文件。

回答by Adam Driscoll

You'll need to compile the library before using it with anything. You can't just install it. Here is a page from their wiki about compiling the library: http://www.cryptopp.com/wiki/Compiling

在将它用于任何东西之前,您需要编译该库。你不能只安装它。这是他们 wiki 关于编译库的页面:http: //www.cryptopp.com/wiki/Compiling

回答by Protoss

If you convert cryptest.sln from VS2005 to VS2010, you will meet a problem. When you compile source code, the compiler will show an error:

如果将 cryptest.sln 从 VS2005 转换为 VS2010,就会遇到问题。当你编译源代码时,编译器会显示一个错误:

c1xx : fatal error C1027: Inconsistent values for /Ym between creation and use of precompiled header

c1xx:致命错误 C1027:在创建和使用预编译头之间 /Ym 的值不一致

You can resolve this problem by:

您可以通过以下方式解决此问题:

  1. Going to Project Properties --> Configuration Properties --> C/C++ --> Precompiled Headers

  2. Changing it to "Not Using Precompiled Headers"

  1. 转到项目属性 --> 配置属性 --> C/C++ --> 预编译头文件

  2. 将其更改为“不使用预编译头”