MySQL thread-unsafe library gets linked? wut? lazarus / 16-Databases ---------------------------------------------------------------------- hinst · 2013-11-22 20:06 I run into some problems in my multithreaded application which uses fcl-db. While searching for answers, here is what I found: MySQL has two client libraries on linux: libmysqlclient.so which is thread-unsafelibmysqlclient_r.so which is thread-safe Then I performed a full-text search in Lazarus directory (which contains FreePascal sources as well)... I searched for "libmysqlclient" string is present in some source files, but libmysqlclient_r is not... So does that mean that fcl-db only links thread-unsafe mysql client library? (whether dynamically or statically is irrelevant at this point. In case my application uses thread-unsafe library, the problems I ran into are most likely are caused by the usage of thread-unsafe library) ---------------------------------------------------------------------- marcov · 2013-11-22 20:15 Override the library name (see the mysql unit for how), and test. This kind of rough speculation isn't beneficial to anyone. ---------------------------------------------------------------------- hinst · 2013-11-22 21:06 I just checked it, but in another way Because to make changes in RTL units such as mysql, I have to recompile the FPC compiler's RTL, and it won't get recompiled automatically when I recompile my applicationIt turns out that it uses "unsafe" library. Here is how I checked: launched my application, then obtained its process id Code: [Select]$ pidof GTIWebServer 10792 Then: Code: [Select]$lsof -P -T -p 10792 ... GTIWebSer 10792 hinst  mem    REG              252,2  1030512  265934 /lib/x86_64-linux-gnu/libm-2.15.so GTIWebSer 10792 hinst  mem    REG              252,2    92720  262373 /lib/x86_64-linux-gnu/libz.so.1.2.3.4 GTIWebSer 10792 hinst  mem    REG              252,2  3412232 2366616 /usr/lib/x86_64-linux-gnu/libmysqlclient.so.18.0.0 GTIWebSer 10792 hinst  mem    REG              252,2  1815224  265923 /lib/x86_64-linux-gnu/libc-2.15.so ... other libraries below It also turns out that FPC loads mysql library dynamically by default (because this command lists only dynamic libraries) One last thing: I checked whether an equal .so file exists but with _r: /usr/lib/x86_64-linux-gnu/libmysqlclient_r.so.18 and it does exist indeed. So everything points to the fact that thread-unsafe MySQL library is being used indeed