Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linking to the correct library

I dont think my question here was answered here already. So here it is, I have a static library that I maintain and update periodically. I also update the version number correctly. Now my application which uses this library must link to exactly the same version of the library and not to the older or newer ones. One thing I tried was to use predefined macros in the libraries header file and check it in my application. It worked, but in that way you can only ensure the correct header files. Is there any technique so that the linking will fail if it is the wrong library?? I hope the question is somewhat clear.

Hari

like image 538
Hari Avatar asked Jan 01 '26 08:01

Hari


1 Answers

All you need is a unique symbol related to the version number for example:

int version_1_1_5=0;

in the library and some use of it in the application, for example:

extern int version_1_1_5; //decl
int *p = &version_1_1_5;  // use
like image 85
Yttrill Avatar answered Jan 03 '26 23:01

Yttrill



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!