简体   繁体   中英

Creating a name space for OpenSSL Library?

Is it possible to create a separate namespace when compiling the OpenSSL Lib? I'm using https://github.com/x2on/OpenSSL-for-iPhone .

The reason I need this is because the current SDK I'm building uses OpenSSL, but when I pass it to the customer, they also uses a different version of OpenSSL, and it is causing duplicate symbol linker errors.

Another question is there a different way for the customer to use our existing SDK without defining our own name space for the OpenSSL Lib?

OpenSSL is a C library. And C does not support namespaces.

If you really have naming conflicts, best way to handle this is using a wrapper library.

Just as illustration a small example.

wrapper.h:

void xxxxxOpenSSLFunction1();
void xxxxxOpenSSLFunction2();
void xxxxxOpenSSLFunction3();

wrapper.cpp

#include <OpenSSL...>
#include <OpenSSL...>

void xxxxxOpenSSLFunction1() { OpenSSLFunction1(); }
void xxxxxOpenSSLFunction2() { OpenSSLFunction2(); }
void xxxxxOpenSSLFunction3() { OpenSSLFunction3(); }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM