I have an autotools C project.
How do I compile a binary which works with both libcrypto.so.0.9.8 and libcryto.so.1.0.0? (i.e. Ubuntu 9.10 and 12.04)
Depending on the age of the OS on which I do the build, the binary requires one version or the other.
Is there a way of making it not care, or are the differences between the libcryto versions insurmountable?
In my opinion, you want to use some function of libcrypto.so.0.9.8 and some from libcryto.so.1.0.0. If most of the functions are required from 1.0.0 or is preferred choice then link with libcrypto.so.1.0.0.
And you may need some function from libcrypto.so.0.9.8 or you may have other good reasons to use libcrypto.so.0.9.8.
In my view, if you link from both the library, you will get linker error (duplicate symbols as both of the library contains same symbols).
If you need to use 0.9.8, then load it dynamically using dlopen and get the function callback which you want use with dlsym.
This can be accomplished as follows:
void * handle;
/*reqd_callback is the callback of required function.*/
reqd_callback cb;
handle = dlopen ("libcrypto.so.0.9.8", RTLD_LAZY);
cb = (reqd_callback)dlsym(handle, "reqd_function");
//Call the cb
cb (parameters);
//Close the library.
dlclose(handle);
I think this may solve your purpose. If the preference is inverse, invert the library in linking and in loading through program.
Can you make a soft link that will "point" to either libcrypto.so.0.9.8 or libcryto.so.1.0.0. Give it a generic name and then use that, then whatever version of the library the link "points" to, will be picked up? On app install, you set your soft link to point to the library version available. Your software might be tested up to 1.0.0 if the lib is backward compatible enough, i.e. you don't rely on somthing in 1.0.0 that's not in 0.9.8, your ok.
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