错误:在C ++项目中使用HMAC_CTX时类型不完整 [英] Error: incomplete type when using HMAC_CTX in C++ project
问题描述
我正在尝试编译该库 ndn-cxx 在我的笔记本电脑上.我已经在另一台计算机上尝试过,并且编译成功,但是现在出现此错误,我认为它与openssl相关.我使用 sudo apt-cache search libssl验证我的笔记本电脑中是否装有openssl | grep SSL ,结果是:
I am trying to compile this library ndn-cxx in my laptop. I already tried in another computer and it compiled successfully but now i am getting this error and i think its related somhow to openssl. I verify that i have openssl in my laptop using sudo apt-cache search libssl | grep SSL and the result is :
- libssl-ocaml-用于OpenSSL(运行时)的OCaml绑定
- libssl-ocaml-dev-用于OpenSSL的OCaml绑定
- libssl0.9.8-SSL共享库
- libsslcommon2-企业消息传递系统-通用SSL库
- libsslcommon2-dev-企业消息传递系统-常见的SSL开发文件
我在尝试编译库时遇到的错误是:
../src/security/transform/hmac-filter.cpp:49:12: error: field ‘m_context’ has incomplete type
HMAC_CTX m_context;
^
../src/security/transform/hmac-filter.cpp: In constructor
‘ndn::security::transform::HmacFilter::Impl::Impl()’:
../src/security/transform/hmac-filter.cpp:35:20: error: ‘m_context’ was not declared in this scope
HMAC_CTX_init(&m_context);
^
../src/security/transform/hmac-filter.cpp:35:29: error: ‘HMAC_CTX_init’ was not declared in this scope
HMAC_CTX_init(&m_context);
^
../src/security/transform/hmac-filter.cpp: In destructor ‘ndn::security::transform::HmacFilter::Impl::~Impl()’:
../src/security/transform/hmac-filter.cpp:40:23: error: ‘m_context’ was not declared in this scope
HMAC_CTX_cleanup(&m_context);
^
../src/security/transform/hmac-filter.cpp:40:32: error: ‘HMAC_CTX_cleanup’ was not declared in this scope
HMAC_CTX_cleanup(&m_context);
^
../src/security/transform/hmac-filter.cpp: In member function ‘ndn::security::transform::HmacFilter::Impl::operator HMAC_CTX*()’:
../src/security/transform/hmac-filter.cpp:45:13: error: ‘m_context’ was not declared in this scope
return &m_context;
^
../src/security/transform/hmac-filter.cpp:46:3: warning: control reaches end of non-void function [-Wreturn-type]
}
^
推荐答案
The file that causes the compilation error contains the line #if OPENSSL_VERSION_NUMBER < 0x1010000fL
and uses the struct HMAC_CTX
in that case. For newer versions of OpenSSL (>1.1.0), it uses HMAX_CTX *
. My conclusion is that the waf
build tool includes the wrong file to get the OPENSSL_VERSION_NUMBER
and consequently compiles as if you are using an older version of OpenSSL, with the struct HMAC_CTX
, which is no longer available as such in the newer versions.
您可以执行grep OPENSSL .waf-tools/openssl.py
并分析打印的行,以查看不同的OpenSSL包含的来源.
You could do grep OPENSSL .waf-tools/openssl.py
and analyse the printed lines to see where the different OpenSSL includes come from.
这篇关于错误:在C ++项目中使用HMAC_CTX时类型不完整的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!