Recent

Author Topic: Cannot load MySQL library "libmysqlclient.so"  (Read 48371 times)

rturney

  • New Member
  • *
  • Posts: 48
Cannot load MySQL library "libmysqlclient.so"
« 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

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2582
RE: Cannot load MySQL library "libmysqlclient.so"
« Reply #1 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.
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

rturney

  • New Member
  • *
  • Posts: 48
Cannot load MySQL library "libmysqlclient.so"
« Reply #2 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?

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2582
Cannot load MySQL library "libmysqlclient.so"
« Reply #3 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 ?
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

rturney

  • New Member
  • *
  • Posts: 48
Cannot load MySQL library "libmysqlclient.so"
« Reply #4 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.

rturney

  • New Member
  • *
  • Posts: 48
Cannot load MySQL library "libmysqlclient.so"
« Reply #5 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.

rturney

  • New Member
  • *
  • Posts: 48
Please help with this error - Can't load MySQL library
« Reply #6 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

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2582
RE: Please help with this error - Can
« Reply #7 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.
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

rturney

  • New Member
  • *
  • Posts: 48
Cannot load MySQL library "libmysqlclient.so"
« Reply #8 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:

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2582
Cannot load MySQL library "libmysqlclient.so"
« Reply #9 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 ?
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

rturney

  • New Member
  • *
  • Posts: 48
Cannot load MySQL library "libmysqlclient.so"
« Reply #10 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

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2582
Cannot load MySQL library "libmysqlclient.so"
« Reply #11 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.
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

rturney

  • New Member
  • *
  • Posts: 48
Cannot load MySQL library "libmysqlclient.so"
« Reply #12 on: April 23, 2007, 04:42:06 pm »
I ran your program and the output was "fail".

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2582
Cannot load MySQL library "libmysqlclient.so"
« Reply #13 on: April 24, 2007, 11:44:34 am »
and what if you use  h := loadlibrary('/usr/lib/mysql/libmysqlclient.so'); ?
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

rturney

  • New Member
  • *
  • Posts: 48
Cannot load MySQL library "libmysqlclient.so"
« Reply #14 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?

 

TinyPortal © 2005-2018