问题
I load the pthread library in my program using dlopen, and fetch handlers to pthread_create and pthread_join using dlsym.
How can I ensure that both the handlers are of a compatible version? I do not care if the symbols are of new version or old versions. I just want that whatever pthread_create I use to work well with the pthread_join that I get.
I know there is a dlvsym to which I can pass explicit version number, but I do not care about exact version numbers as I want my code to be independent of library versions.
回答1:
The only reason the versioning exists is for a poor attempt at ABI-compatibility with programs compiled against ancient versions of glibc, which will not actually work anyway. (They've silently broken the ABI at least once in a way that, as far as I can tell, cannot be compatible.) Just ignore it.
回答2:
Sounds like you need "dladdr - find the shared object containing a given address".
However as you have not said what platform you are using, so it might not be available.
Have a look and see..
来源:https://stackoverflow.com/questions/5587718/symbol-versioning-and-dlsym