Lazarus
Programming => Databases => Topic started 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:
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:
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:
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:
-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
-
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.
-
Thanks for the help. The libmysqlclient.so.15.0.0 is in /usr/lib and the contents of ld.so.conf is:
include ld.so.conf.d/*.conf
What exactly should I put in ld.so.conf?
-
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 /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 ?
-
Do you have a mixed 32/64 bit system ?
No, I am running 32 bit.
Does a commandline mysql client work ?
Yes, mysqld starts at boot up, and I can log in with either
$ mysql -u root -p
or
# mysql -u root -p
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.
-
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.
-
I have been stumped on this error for weeks and don't know what to do.
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)
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
-
Please keep it in one thread. Creating more threads won't solve your problem.
I'll need to lookup where this message comes from.
-
Please accept my apologies. I thought the topic had died. I will be more patient in the future. :oops:
-
Sorry took some time.
The message is generated by the following piece of code: 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 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:
$ 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:
$ 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
-
I'm out of options. What you can try si the following program:
program mysqltest;
uses
dynlibs;
var
h: TLibHandle;
begin
h := loadlibrary('libmysqlclient.so');
if h = nilhandle
then WriteLN('fail')
else WriteLN('success');
end.
-
I ran your program and the output was "fail".
-
and what if you use h := loadlibrary('/usr/lib/mysql/libmysqlclient.so'); ?
-
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?
-
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) 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 /sbin/ldconfig -p |grep mysql
show ?
and what does file -L /usr/lib/mysql/libmysqlclient.so
-
/sbin/ldconfig -p |grep mysql
shows:
libmysqlclient_r.so.15 (libc6) => /usr/lib/libmysqlclient_r.so.15
libmysqlclient.so.15 (libc6) => /usr/lib/libmysqlclient.so.15
file -L /usr/lib/mysql/libmysqlclient.so
shows:
/usr/lib/mysql/libmysqlclient.so: cannot open `/usr/lib/mysql/libmysqlclient.so' (No such file or directory)
-
aha....
Create a symlink in the /usr/lib/mysql dir like I did. See previous message
-
I had some minor success! I switched to /usr/lib/mysql and as root did:
ln -s libmysqlclient.so.15 libmysqlclient.so
Then, still as root, did:
ldconfig -v
under /usr/lib it showed:
libmysqlclient.so.15 -> libmysqlclient.so.15.0.0
libmysqlclient_r.so.15 -> libmysqlclient_r.so.15.0.0
Then I did:
/sbin/ldconfig -p |grep mysql
which returned:
libmysqlclient_r.so.15 (libc6) => /usr/lib/libmysqlclient_r.so.15
libmysqlclient.so.15 (libc6) => /usr/lib/libmysqlclient.so.15
Next,
file -L /usr/lib/mysql/libmysqlclient.so
Which returned:
/usr/lib/mysql/libmysqlclient.so: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), stripped
I then ran the original console program you had written using:
h := loadlibrary('libmysqlclient.so');
but it returned "fail"
Then I ran it with:
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)
ln -s libmysqlclient.so.15 /usr/lib/libmysqlclient.so
?????? If so should I remove the sym link I just put in /usr/lib/mysql ?
-
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)
-
In /usr/lib I created the sym link:
ln -s libmysqlclient.so.15 libmysqlclient.so
Now, the fpc program with the line:
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.
-
please try in synaptic package manager install libmysqlclient15-dev
thx
-
sudo ln -s /usr/lib/libmysqlclient.so.16.0.0 /usr/lib/libmysqlclient.so.15
it work for me in ubuntu 10.10