[Lazarus] Dynamic loading of a custom sqlite library

Max Vlasov max.vlasov at gmail.com
Thu Jun 9 11:17:22 CEST 2011


On Wed, Jun 8, 2011 at 6:27 PM, Max Vlasov <max.vlasov at gmail.com> wrote:

> Hi,
>
> I encountered problems using dynamically loaded sqlite library with lazarus
> on linux.
> My post about this in the sqlite list is here:
> http://www.mail-archive.com/sqlite-users@sqlite.org/msg61565.html
> Maybe someone points me to the right direction
>
> It's about loading sqlite library with dlopen, getting all the methods with
> dlsym and using it. I intentionally use different name and soname to not to
> conflict with the system name (libsqlite3.so)
>
> It works if I use default libsqlite3 library installed with ubuntu package
> system in dlopen.
>
> But if I compile the latest sqlite by myself or use configurable sqlite
> download with default options, I get SIGSEGV errors inside sqlite code and
> they appear inside dlopen is called (this is because sqlite3_initialize is
> defined to be executed when the library is beeing loaded).
> ...
>

Finally found that this was because sqlite3 was in the uses list, so
actually it was scenario when fpc linked sqlite dynamically and besides I
did my own dynamic loading with my own unit of another version/file of
sqlite. So probably there was a conflict with shared data. In my case it
looks like everything was ok if the linked library and loaded was the same
file (system libsqlite3.so). But if linked was system libsqlite3.so and my
loaded was a library with a different name/soname the faults took place.

Just curious, such things occasionally can happen from time to time. Is this
about the way sqlite library is compiled so no two independent copies of the
library coexist dynamically linked/loaded due to intersetion of the shared
data. Or this is about the way linux handles them?

Thanks

Max
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20110609/6c8be621/attachment-0003.html>


More information about the Lazarus mailing list