在 Visual C++ 中设置 botan
Setting up botan in visual C++
出于某种原因,我想到了使用 botan 连接到 PKCS11 硬件令牌。我是 C++ 的新手,想用 Visual Studio 2019 编写代码。
我下载了 botan 源代码并使用 nmake 构建了源代码。构建完成后,创建一个名为 build 的文件夹。
我把botan的目录添加到VC++目录[右击应用-->属性-->VC++目录]
#include <iostream>
#include <botan\botan.h>
#include <botan\alg_id.h>
#include <external\pkcs11t.h>
#include <external\pkcs11f.h>
#include <external\pkcs11.h>
int main() {
Botan::Dynamically_Loaded_Library pkcs11_module("C:\pkcs11-middleware\library.dll");
Botan::PKCS11::FunctionListPtr func_list = nullptr;
Botan::PKCS11::LowLevel::C_GetFunctionList(pkcs11_module, &func_list);
Botan::PKCS11::LowLevel p11_low_level(func_list);
}
这些行有错误
namespace Botan没有成员"Dynamically_Loaded_Library"
牡丹::Dynamically_Loaded_Library
名称后跟“::”必须是 class 或命名空间
所有的台词都有错误,我真的搞错了。帮助将不胜感激
- 构建博坦源码:
1-1. Open developer command prompt for visual studio 2019
1-2. python "c:\botan\configure.py" --cc=msvc --cp=i386
1-3. nmake
1-4. python "c:\botan\install.py"
1-5. nmake install
- 右键单击 visual studio 中的应用程序 --> 属性 --> VC++ 目录
2-1. Include Directories: Add C:\Botan\include\botan-2
2-2. Library Directories: Add C:\Botan\lib
右击visual studio中的application --> properties --> Linker --> input --> Additional Dependencies --> add botan.lib
不要忘记将调试模式设置为 x86
感谢@Alexander,我应该包含“p11.h”并使用命名空间 PKCS11 进行定义;
重建项目:)
出于某种原因,我想到了使用 botan 连接到 PKCS11 硬件令牌。我是 C++ 的新手,想用 Visual Studio 2019 编写代码。
我下载了 botan 源代码并使用 nmake 构建了源代码。构建完成后,创建一个名为 build 的文件夹。
我把botan的目录添加到VC++目录[右击应用-->属性-->VC++目录]
#include <iostream>
#include <botan\botan.h>
#include <botan\alg_id.h>
#include <external\pkcs11t.h>
#include <external\pkcs11f.h>
#include <external\pkcs11.h>
int main() {
Botan::Dynamically_Loaded_Library pkcs11_module("C:\pkcs11-middleware\library.dll");
Botan::PKCS11::FunctionListPtr func_list = nullptr;
Botan::PKCS11::LowLevel::C_GetFunctionList(pkcs11_module, &func_list);
Botan::PKCS11::LowLevel p11_low_level(func_list);
}
这些行有错误
namespace Botan没有成员"Dynamically_Loaded_Library"
牡丹::Dynamically_Loaded_Library
名称后跟“::”必须是 class 或命名空间
所有的台词都有错误,我真的搞错了。帮助将不胜感激
- 构建博坦源码:
1-1. Open developer command prompt for visual studio 2019
1-2. python "c:\botan\configure.py" --cc=msvc --cp=i386
1-3. nmake
1-4. python "c:\botan\install.py"
1-5. nmake install
- 右键单击 visual studio 中的应用程序 --> 属性 --> VC++ 目录
2-1. Include Directories: Add C:\Botan\include\botan-2
2-2. Library Directories: Add C:\Botan\lib
右击visual studio中的application --> properties --> Linker --> input --> Additional Dependencies --> add botan.lib
不要忘记将调试模式设置为 x86
感谢@Alexander,我应该包含“p11.h”并使用命名空间 PKCS11 进行定义;
重建项目:)