c++ - 如何在 VC++ 中将 Botan 加密库编译为静态库?

标签 c++ visual-c++ cryptography botan

我在将 Botan 编译为 Visual C++ 中的静态库时非常失败。 build.h 文件包含以下代码:

#ifndef BOTAN_DLL
  #define BOTAN_DLL __declspec(dllexport)
#endif

此宏随后几乎出现在 Botan 代码库的任何地方,如下所示:

class BOTAN_DLL AutoSeeded_RNG : public RandomNumberGenerator

我对 previous question 的理解是你需要做的就是定义没有值的 BOTAN_DLL 并且它应该编译为静态库就好了。然而,这样做会导致大量构建错误,例如“缺少标签名称”。有人知道怎么做吗?

编辑:这是将/D "BOTAN_DLL"添加到 makefile 所导致的错误示例:

        cl.exe /Ibuild\include /O2  /EHsc /GR /D_CONSOLE /D "BOTAN_DLL"  /nologo
 /c src\checksum\adler32\adler32.cpp /Fobuild\lib\adler32.obj
adler32.cpp
build\include\botan/allocate.h(19) : error C2332: 'class' : missing tag name
build\include\botan/allocate.h(19) : error C2143: syntax error : missing ';' bef
ore 'constant'
build\include\botan/allocate.h(19) : error C2059: syntax error : 'constant'
build\include\botan/allocate.h(20) : error C2143: syntax error : missing ';' bef
ore '{'
build\include\botan/allocate.h(20) : error C2447: '{' : missing function header
(old-style formal list?)
build\include\botan/secmem.h(229) : error C2143: syntax error : missing ';' befo
re '*'
        build\include\botan/secmem.h(230) : see reference to class template inst
antiation 'Botan::MemoryRegion<T>' being compiled
build\include\botan/secmem.h(229) : error C4430: missing type specifier - int as
sumed. Note: C++ does not support default-int

最佳答案

我最近需要自己构建一个静态的 Botan 库,虽然这是一个相当古老的线程,但我想我会发布一个答案。我相信执行此操作的“预期”方法是使用配置选项。如果你指定

configure.py --disable-shared

然后生成的 makefile 构建静态 botan.lib 而不是 .dll。它还生成包含

#ifndef BOTAN_DLL
  #define BOTAN_DLL 
#endif

关于c++ - 如何在 VC++ 中将 Botan 加密库编译为静态库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/995253/

相关文章:

c++ - 在 C++ 中比较两种数据类型?

visual-c++ - System::String^ 到十六进制表示,需要帮助

java - 在不知道 key 的情况下对 secret 后缀进行密码学解密

.net - Crypto API 中交换 key 和签名 key 的区别

c++ - std::vector Reserve() 的未定义行为

c++ - 是否可以只使用 QT 和 WebAssembly(而不是 HTML + CSS + JavaScript)来开发前端 Web?

c++ - 在 VC++ 中,数组的长度不会在运行时得到验证吗?

c++ - 为什么编译器不提示 catch 子句?

delphi - 如何使用 CryptoAPI 加载 OpenSSL 生成的 RSA1024 纯文本公钥?

c# - c++和c#之间通过管道进行通信