You're right. My scenario doesn't cause a problem. All symbols are resolved before lib2 is loaded and loading lib2 won't change the symbols alread resolved. It would only affect new symbol lookups after lib2 is loaded and when using dlopen(nil,...). Ludo
-----Message d'origine----- De : Max Vlasov [mailto:[email protected]] Envoyé : dimanche 12 juin 2011 11:41 À : Lazarus mailing list Objet : Re: [Lazarus] RE : RE : Dynamic loading of a custom sqlite library 2011/6/12 Ludo Brands <[email protected]> > So what did you mean by saying 'dangerous'? You should have read a little further in the message: "Possibly everything is fine for sqlite3 but documenting it as a general solution is IMHO not correct.". The scenario I was talking about assumed an initialization (before lib2 is loaded) and a finalization routine which would/could run in different librarie. This is not the case in your example. I proposed to test if the library was loaded before loading again as a more general solution to the problem. Don't get me wrong. I'm happy this is working for you. I'm only saying it is not a good idea to document/promote this as a general solution for avoiding problems with double loaded libraries. Ludo, ok, I just tried to see the level of the problem you described. I just recently found this flag so I want to be sure it is working as I expect. You wrote in your previous post "At the end the unit that used lib1 could execute some finalization routines. But this time they run in lib2". I don't see why a function (let's call it somelibrary_somefinalize()) linked with external directive and used somewhere in the sources should be called from the lib2 this time (if RTLD_DEEPBIND flag is used). For dynamic loading there's always a variable and this new address was obtained with dlsym call and this is the only place that aware of lib2.somelibrary_somefinalize. I may be wrong, but this is how I understood the logic behind it. I recently saw that I was wrong assuming that read-only code and data is safe, because there are usually different versions of libraries so to ensure imho any symbol should be bind separately. Max
-- _______________________________________________ Lazarus mailing list [email protected] http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
