I'm writing a cross-platform C++ library which relies upon OpenSSL, which I link statically & bundle with my library for easy consumption. I would like to have a single #include directory for my library, which would obviously contain an "openssl" subdirectory.
Unfortunately, contents of the OpenSSL #include directory are different per architecture, per platform. So, for example, there are (minimally) three different versions of OpenSSL header files for iOS. Add more for TV-OS support and simulator versions. The same problem exists to different degrees on Windows & Android.
Upon closer examination, the only file that's common but different across all platforms & architectures is "opensslconf.h", and it usually only differs by a few lines, or sometimes even a single line.
For example, the tvOS version of "opensslconf.h" contains:
#ifndef OPENSSL_NO_ASYNC
# define OPENSSL_NO_ASYNC
#endif
Whereas the iOS version does not.
A more frequent difference is in the definition of RC4_INT:
// 64-bit architectures?
#define RC4_INT unsigned int
// 32-bit architectures?
#define RC4_INT unsigned char
I would like to have only ONE set of OpenSSL #includes that applies to all architectures & platforms. I don't want to have duplicates of all these files for every arch/platform, especially since there are so many variations.
My first question is if it's possible to have just one OpenSSL #include directory as I'd like? If so, which version of "opensslconf.h" should I choose, and how do I know it will work?
My second question is why this is an issue AT ALL. Why can't these platform differences be encapsulated by OpenSSL? Isn't it already keeping track of many other variables and types that change as you build for different architectures?
As a workaround, you can generate several versions of opensslconf.h
(one for each of archs you plan to support), call them opensslconf-win.h
, opensslconf-tvos.h
, etc.
Then write an opensslconf which will contain only includes of the generated files based on platform:
#ifdef WIN32
#include opensslconf-win.h
#endif
// and so for every arch
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With