Reputation: 341
In an XCode project I have linkend a library (libpng) and a framework (opencv). The framework already contains an older version of my library.
Now when I go to XCode in "Link Binary With Libraies", if I put opencv first and libpng second, my code will use the what is in opencv, i.e. the older version.
My question: Is it possible to know at compile time which version of libpng my project will use? I want to know for sure that even if somebody messes with the order my libraries are linked, I still use the proper one.
What I tried already is to check with compile directives the version of libpng, something like this:
#if PNG_LIBPNG_VER_MINOR !=6
#error "Wrong libpng version. Required is 1.6.9."
#endif
But this is not a solution since the header where PNG_LIBPNG_VER_MINOR
is declared is always the correct one. It's just in the code that the wrong methods might be called.
Thanks!
Upvotes: 2
Views: 1553
Reputation: 104698
Is it possible to know at compile time which version of libpng my project will use?
Not in this case. A translation's parameters are different from the linker's. There is no guarantee.
Upvotes: 1