Lazarus

Programming => Databases => Topic started by: rturney on March 18, 2007, 05:05:49 pm

Title: Cannot load MySQL library "libmysqlclient.so"
Post by: rturney on March 18, 2007, 05:05:49 pm
I am using Fedora Core 6, MySQL 5.0.27 and Lazarus 0.9.20 and I have been working on the MySQL tutorial for Lazarus http://wiki.lazarus.freepascal.org/MySQLDatabases I have the entire tutorial saved and it compiles with no problems (I am using "TMySQL50Connection").  During run-time I enter "localhost" for the Host input and "root" for the Username input.  I leave the Password input Empty (because that is how my MySQL root user is set).  When I click the "Connect to server" button I get the following error:

Quote
Can not load MySQL library "libmysqlclient.so" Please check your installation.


The first time I encountered this error I realized I did not have the mysql-devel package installed, which contains libmysqlclient.so.  After installing it I got the same error.  Then I searched the Lazarus forum and saw a recommendation to add these symbolic links in /usr/lib.  I checked to make sure libmysqlclient.so was in /usr/lib (it was) and then did:

Code: [Select]
ln -s libmysqlclient.so.15.0.0 lmysqlclient
ln -s libmysqlclient.so.15.0.0 libmysqlclient.so
ln -s libmysqlclient.so.15.0.0 mysqlclient


This did not help.  I got the same error. So I added the paths:

Code: [Select]
ln -s /usr/lib/libmysqlclient.so.15.0.0 /usr/lib/lmysqlclient
ln -s /usr/lib/libmysqlclient.so.15.0.0 /usr/lib/libmysqlclient.so
ln -s /usr/lib/libmysqlclient.so.15.0.0 /usr/lib/mysqlclient


This did not help, same error.

I read about getting MySQL to work for FPC in text mode. http://lazarus-ccr.sourceforge.net/index.php?wiki=LazarusDatabase Among other things it suggested adding a line to /etc/fpc.cfg to point to my libraries:

Code: [Select]
-Fl/lib;/usr/lib

I did this and got the same error!

I am hoping that someone knows what I am doing wrong and would be kind enough to help me fix this problem.

Thanks,
-Bob
Title: RE: Cannot load MySQL library "libmysqlclient.so"
Post by: Marc on March 19, 2007, 12:28:43 pm
If you  have installed the devel package, you don't have to mess with symbolic links manually. I would advise you to remove the ones you added, since this makes error tracking more difficult.
Locate where the devel package has installed the libmysqlclient.so and check if this path is located in your systems ld.so.conf (or a similar named file)
The -Fl line in fpcconfig is onlt needed for compiling, not for running apps at runtime.
Title: Cannot load MySQL library "libmysqlclient.so"
Post by: rturney on March 19, 2007, 01:14:56 pm
Thanks for the help.  The libmysqlclient.so.15.0.0 is in /usr/lib and the contents of ld.so.conf is:
Quote
include ld.so.conf.d/*.conf


What exactly should I put in ld.so.conf?
Title: Cannot load MySQL library "libmysqlclient.so"
Post by: Marc on March 19, 2007, 01:48:15 pm
Long live all those different configurations :(
my libmysqlclient.so.14.0.0 is located in /usr/lib/mysql/ and my /etc/ld.so.conf.d/mysql-i386.conf contains only one line
Code: [Select]
/usr/lib/mysql/
Since yours is located in /usr/lib nothing has to be changed, since that dir is included by default

Do you have a mixed 32/64 bit system ?
Does a commandline mysql client work ?
Title: Cannot load MySQL library "libmysqlclient.so"
Post by: rturney on March 19, 2007, 04:12:26 pm
Quote
Do you have a mixed 32/64 bit system ?

No, I am running 32 bit.

Quote
Does a commandline mysql client work ?

Yes, mysqld starts at boot up, and I can log in with either

Code: [Select]
$ mysql -u root -p
or
# mysql -u root -p


Quote
my libmysqlclient.so.14.0.0 is located in /usr/lib/mysql/ and my /etc/ld.so.conf.d/mysql-i386.conf contains only one line

I was in a hurry this morning and now I am wondering if I stated the location correctly?!?!?  I will recheck at lunch when I can get to my Linux machine.  I hope I didn't give the wrong location  :oops: I'll confirm in my next post.
Title: Cannot load MySQL library "libmysqlclient.so"
Post by: rturney on March 19, 2007, 06:20:03 pm
I'm sorry.  After checking again I found that libmysqlclient.so.15.0.0 is located in /usr/lib/mysql/.  I was mistakenly looking at the "link" in /usr/lib/.  Also, my /etc/ld.so.conf.d/mysql-i386.conf also contains only one line: /usr/lib/mysql.  It appears that I have the same settings as you do except for libmysqlclient.so.15.0.0 instead of libmysqlclient.so.14.0.0

I can start mysql with no problem as either normal or root user.
Title: Please help with this error - Can't load MySQL library
Post by: rturney on March 23, 2007, 04:52:55 am
I have been stumped on this error for weeks and don't know what to do.  
Quote
Can't load MySQL library "libmysqlclient.so" Please check your installation

I posted last week but found no solution:
http://www.lazarus.freepascal.org/index.php?name=PNphpBB2&file=viewtopic&t=3548

The library "libmysqlclient.so" is installed in /usr/lib/mysql and my /etc/ld.so.conf.d/mysql-i386.conf contains "/usr/lib/mysql".  

MySQL runs fine by itself.  I only have trouble when I try to use Lazarus with MySQL.  Below is the output from mysql status (\s)

Quote
mysql  Ver 14.12 Distrib 5.0.27, for redhat-linux-gnu (i686) using readline 5.0

Connection id:          3
Current database:
Current user:           root@localhost
SSL:                    Not in use
Current pager:          stdout
Using outfile:          ''
Using delimiter:        ;
Server version:         5.0.27
Protocol version:       10
Connection:             Localhost via UNIX socket
Server characterset:    latin1
Db     characterset:    latin1
Client characterset:    latin1
Conn.  characterset:    latin1
UNIX socket:            /var/lib/mysql/mysql.sock
Uptime:                 5 days 4 hours 29 min 19 sec

Threads: 1  Questions: 11  Slow queries: 0  Opens: 12  Flush tables: 1  Open tables: 6  Queries per second avg: 0.000


I am running Fedora Core 6 and MySQL 5.0.27 and Lazarus 0.9.30

Any suggestions would be greatly appreciated.
Thanks
-Bob
Title: RE: Please help with this error - Can
Post by: Marc on March 23, 2007, 04:56:07 pm
Please keep it in one thread. Creating more threads won't solve your problem.

I'll need to lookup where this message comes from.
Title: Cannot load MySQL library "libmysqlclient.so"
Post by: rturney on March 23, 2007, 05:32:58 pm
Please accept my apologies.  I thought the topic had died.  I will be more patient in the future.  :oops:
Title: Cannot load MySQL library "libmysqlclient.so"
Post by: Marc on April 18, 2007, 08:14:06 pm
Sorry took some time.

The message is generated by the following piece of code:
Code: [Select]
   MysqlLibraryHandle := loadlibrary(LibraryName);
    if (MysqlLibraryHandle=nilhandle) then
      begin
      Raise EInOutError.CreateFmt(SLoadFailed,[LibraryName]);
      end;

So loadlibrary('libmysqlclient.so'); fails

are you sue libmysqlclient.so is not some symlink to a non existing file ?
Title: Cannot load MySQL library "libmysqlclient.so"
Post by: rturney on April 23, 2007, 06:52:52 am
I was experimenting with Fedora Core 6, but because of other problems, I went back to SUSE 10.2.  I retried the same code that was causing the "Can not load MySQL library libmysqlclient.so" in FC6 and got the same error in SUSE 10.2.  

I have carefully checked the location and properties of "libmysqlclient.so.15.0.0" and in SUSE 10.2, the actual shared library (1.3 MB) is located in /usr/lib with -rwxr-xr-x.  There is a symbolic link located in /usr/lib/mysql.  In SUSE 10.2, my /etc/ld.so.conf.d does not contain "mysql-i386.conf".  I created it with the contents "/usr/lib/" and got the same error.  I edited it to contain "/usr/lib/mysql/" and still got the error.

The mysql daemon, mysqld starts at boot-up.  I checked to make sure:

Code: [Select]
$ ps aux
root      3628  0.0  0.1   2632  1256 ?        S    Apr21   0:00 /bin/sh /usr/bin/mysqld_safe --mysqld=mysqld --user=mysql --pid-file=/var/lib/mysql/mysqld.pid --socket=/var/lib/mysql.sock

mysql     3784  0.0  1.5 109896 15988 ?        Sl   Apr21   0:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/lib/mysql/mysqld.pid --skip-ext



I can run MySQL from the command line.  I start it by issuing:
Code: [Select]
$ mysql -u root -p

I do not run "mysql -u root -p" when running the Lazarus program, just the mysqld is running. Then I enter "localhost" for the Host input, "root" for the User input and the MySQL root password for the password input.  When I click the Connect button I get the error.

I am baffled why I can't get this to work  :shock:
Thanks for your effort to help me solve this problem.  Maybe something I've mentioned here will uncover what's going on.

-Bob
Title: Cannot load MySQL library "libmysqlclient.so"
Post by: Marc on April 23, 2007, 10:57:07 am
I'm out of options. What you can try si the following program:
Code: [Select]
program mysqltest;
uses
  dynlibs;
var
  h: TLibHandle;
begin
  h := loadlibrary('libmysqlclient.so');
  if h = nilhandle
  then WriteLN('fail')
  else WriteLN('success');
end.
Title: Cannot load MySQL library "libmysqlclient.so"
Post by: rturney on April 23, 2007, 04:42:06 pm
I ran your program and the output was "fail".
Title: Cannot load MySQL library "libmysqlclient.so"
Post by: Marc on April 24, 2007, 11:44:34 am
and what if you use  h := loadlibrary('/usr/lib/mysql/libmysqlclient.so'); ?
Title: Cannot load MySQL library "libmysqlclient.so"
Post by: rturney on April 25, 2007, 01:58:47 am
Quote
and what if you use h := loadlibrary('/usr/lib/mysql/libmysqlclient.so'); ?


I tried that and also with /usr/lib/libmysqlclient.so but got the same result: "fail".

Thanks for trying to figure this out.  I assume you are not having this problem.  What Linux distro are you using? Are you using Lazarus 0.9.20?
Title: Cannot load MySQL library "libmysqlclient.so"
Post by: Marc on April 25, 2007, 11:02:28 am
ok, my first test failed also, I was missing a symlink libmysqlclient.so -> libmysqlclient.so.14 (I use FC4)
after creating the link and doing (as root)
Code: [Select]
ldconfig -v the testapp succeeded.
For this testapp, the lazarus version is not important, it is pure fpc. I tested with fpc 2.0.0 2.0.2 2.0.4 and 2.1.3

what does
Code: [Select]
/sbin/ldconfig -p |grep mysql show ?
and what does
Code: [Select]
file -L /usr/lib/mysql/libmysqlclient.so
Title: Cannot load MySQL library "libmysqlclient.so"
Post by: rturney on April 26, 2007, 02:21:32 am
Code: [Select]
/sbin/ldconfig -p |grep mysql  
shows:


Code: [Select]
file -L /usr/lib/mysql/libmysqlclient.so
shows:
Title: Cannot load MySQL library "libmysqlclient.so"
Post by: Marc on April 26, 2007, 11:46:54 am
aha....
Create a symlink in the /usr/lib/mysql dir like I did. See previous message
Title: Cannot load MySQL library "libmysqlclient.so"
Post by: rturney on April 27, 2007, 06:33:05 am
I had some minor success!  I switched to /usr/lib/mysql and as root did:
Code: [Select]
ln -s libmysqlclient.so.15 libmysqlclient.so
Then, still as root, did:
Code: [Select]
ldconfig -v
under /usr/lib it showed:

Then I did:
Code: [Select]
/sbin/ldconfig -p |grep mysql
which returned:

Next,
Code: [Select]
file -L /usr/lib/mysql/libmysqlclient.so
Which returned:


I then ran the original console program you had written using:
 
Code: [Select]
h := loadlibrary('libmysqlclient.so'); but it returned "fail"

Then I ran it with:
Code: [Select]
h := loadlibrary('/usr/lib/mysql/libmysqlclient.so'); and it returned "success" !!!!!!!!!!!!:D

I think the loadlibrary('libmysqlclient.so') failed because without the path, it will look in /usr/lib and libmysqlclient.so is not there ???? Also, since I am in SUSE 10.2, my /etc/ld.so.conf.d does not contain "mysql-i386.conf".  Maybe I need to do a sym link to usr/lib ??? Would this make sense:
(executing from /usr/lib/mysql)
Code: [Select]
ln -s libmysqlclient.so.15 /usr/lib/libmysqlclient.so
??????  If so should I remove the sym link I just put in /usr/lib/mysql ?
Title: Cannot load MySQL library "libmysqlclient.so"
Post by: Marc on April 27, 2007, 11:55:24 am
This thread started at a FC6 machine. There you have a /usr/lib/mysql in the library search path. If you don't have a "mysql-i386.conf" or a /etc/ld.so.conf.d dir, then your disrto doesnt' use this way of config.
in that case, it in /usr/lib (so in the same dir where the libmysqlclient.so.15.0.0 is)
Title: Cannot load MySQL library "libmysqlclient.so"
Post by: rturney on April 27, 2007, 02:08:26 pm
In /usr/lib I created the sym link:
Code: [Select]
ln -s libmysqlclient.so.15 libmysqlclient.so
Now, the fpc program with the line:
Code: [Select]
h := loadlibrary('libmysqlclient.so');
returns "success"

Also, now the Lazarus MySQL tutorial program does not crash because of the "can't load MySQL library libmysqlclient.so" and is connecting to MySQL!!!!

Thank you very much for your patience and help.
Title: Cannot load MySQL library "libmysqlclient.so"
Post by: oting on November 05, 2008, 10:03:52 am
please try in synaptic package manager install libmysqlclient15-dev


thx
Title: Re: Cannot load MySQL library "libmysqlclient.so"
Post by: kriengten on February 23, 2011, 04:12:03 pm
sudo ln -s /usr/lib/libmysqlclient.so.16.0.0 /usr/lib/libmysqlclient.so.15

it work for me in ubuntu 10.10
TinyPortal © 2005-2018