Resolving a symbol in memory
-
Hi,
My problem is the following: I have a Qt application that depends on a shared library. Thus, this shared library is automatically loaded in memory when my application starts.
Now, I want to check for a symbol in this library (which doesn't only depends on the library version). How can I do ?
When I use QLibrary, I have to call 'QLibrary::load' to resolve the symbol but the library is supposed to be already loaded. Isn't it possible to query the symbols available in memory ?Dominique
-
Why would the symbols be available in memory if your application already got the relevant pointers at the link stage?
There's a good possibility that QLibrary::load() won't actually load the library again. It just needs to know about the exported symbols. I'm not sure though. Did you try and see what the results were?
-
bq. Why would the symbols be available in memory if your application already got the relevant pointers at the link stage?
actually it doesn't since I don't make an explicit reference to the symbol and I want to avoid that. It's a kind of dynamic weak link.
bq. There’s a good possibility that QLibrary::load() won’t actually load the library again. It just needs to know about the exported symbols. I’m not sure though. Did you try and see what the results were?
I though about that possibility (library not loaded again) but how can I check ?
-
So you're just dynamically linking?
-
yes, but only partially since the other symbols are resolved the usual way.
Actually I don't want the application to issue a link error at run time for a specific symbol (which I can safely ignore when not present - I simply disable the corresponding feature) -
libraries are loaded with some kind of ref counting. It is safe to load them twice, but take care to also release them twice. Otherwise they are removed only at the end of the application.
-
ok
thanks, that should solve my problem.