CopernicaMarketingSoftware / AMQP-CPP

C++ library for asynchronous non-blocking communication with RabbitMQ
Apache License 2.0
884 stars 340 forks source link

Static tcp library without flags (lssl... ) #525

Closed fvisztra closed 7 months ago

fvisztra commented 7 months ago

the library works well when I build my executable with flags (-lssl) but I would like to build a library with I don't have to add these flags to build an executable...

Thank you for your advice

EmielBruijntjes commented 7 months ago

This is possible indeed. In your own program, you must then load openssl dynamically by calling dlopen():

// open the openssl library (so that we do not hane to link with "-lssl"
auto handle = dlopen("/path/to/libssl.so.X.Y.Z", RTLD_NOW | RTLD_DEEPBIND);

// tell amqpcpp to use this handle
AMQP::openssl(handle);

Note that you can also rely on the library-path (which is nornally set to something like /lib and /usr/lib). In that case you can just specify dlopen("libssl.so.X.Y.Z", ...);