0

I have a C++ code which uses Openssl 1.1.1a. When this c++ code is executed in gcc4.4 there is link error

undefined reference to `EVP_CIPHER_CTX_init'
undefined reference to `EVP_CIPHER_CTX_cleanup'

The same c++ code is building file with windows.

It uses EVP_CIPHER_CTX_init() & EVP_CIPHER_CTX_cleanup() from evp.h of openssl.

In evp.h these macros are defined as below.

# if OPENSSL_API_COMPAT < 0x10100000L
#  define EVP_CIPHER_CTX_init(c)      EVP_CIPHER_CTX_reset(c)
#  define EVP_CIPHER_CTX_cleanup(c)   EVP_CIPHER_CTX_reset(c)
# endif

Somewhere in opensslconf.h the following is declared

#ifndef OPENSSL_MIN_API
# define OPENSSL_MIN_API 0
#endif

#if !defined(OPENSSL_API_COMPAT) || OPENSSL_API_COMPAT < OPENSSL_MIN_API
# undef OPENSSL_API_COMPAT
# define OPENSSL_API_COMPAT OPENSSL_MIN_API
#endif

So ideally OPENSSL_API_COMPAT should be initialized to 0 which would have defined the two functions which are linked by the C++ code.

Somehow these two functions are not defined while building in gcc4.4.

I tried defining the OPENSSL_API_COMPAT to 0 while building using -DOPENSSL_API_COMPAT=0 but still no luck

Ideally these functions should be defined when the macro OPENSSL_API_COMPAT is set to 0. No where else this macro is manipulated in c++ code or other library.

What and where could the macro be altered ? Would be of great help if any openssl expert give some insight here.

  • 2
    Sounds like a version-conflict: old headers mixed with new libraries. – Lorinczy Zsigmond Apr 12 '19 at 10:43
  • @LorinczyZsigmond I re-compiled the openssl 1.1.1a in gcc4.4 and using the include file and the libraries extracted from it. So it is all same. – Deepak Selvakumar Apr 12 '19 at 11:01
  • I mean you should compile your C++ program with the new headers and link it with the new libraries. – Lorinczy Zsigmond Apr 12 '19 at 11:04
  • @LorinczyZsigmond, you mean linking to new openssl libraries, right ? Yes, the C++ code is built including the new headers and linked with new libs of openssl 1.1.1a – Deepak Selvakumar Apr 12 '19 at 11:16
  • I think it is new headers and old libraries (0.9.6 openssl). Maybe post the linker invocation. Openssl 1.1 might be installed as libssl-1.1 or something similar. – arved Apr 12 '19 at 12:39

0 Answers0