Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
782 views
in Technique[技术] by (71.8m points)

ssl - Error: incomplete type when using HMAC_CTX in C++ project

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 - OCaml bindings for OpenSSL (runtime)
  • libssl-ocaml-dev - OCaml bindings for OpenSSL
  • libssl0.9.8 - SSL shared libraries
  • libsslcommon2 - enterprise messaging system - common SSL libraries
  • libsslcommon2-dev - enterprise messaging system - common SSL development files

The error I am getting when trying to compile the library is :

../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]
   }
   ^
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

You could do grep OPENSSL .waf-tools/openssl.py and analyse the printed lines to see where the different OpenSSL includes come from.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...