MySQL client
Hi all,
I am taking some steps into programming with the MySQL C APIs for an upcoming project. I have this code, mostly working from the MySQL documentation: Code:
Code:
[root@crashbox examples]# gcc -Wall -o aoe aoe.c |
You forgot to link with the mysql client library.
Compile with this: Code:
gcc -Wall -lmysqlclient -o aoe aoe.c |
Hi Hko,
Thanks for your reply. When I try that, here is what I get: Code:
[root@crashbox examples]# gcc -Wall -lmysqlclient -o aoe aoe.c TIA |
Do you have both of these installed?
mysql-3.23.54a-11.i386.rpm mysql-devel-3.23.54a-11.i386.rpm To be on the safe side, run "ldconfig" as root after installing both. If this doesn't help, try to find the file "libmysqlclient.so", and put the directory where you find it in the -L options of gcc. Code:
gcc -Wall -L/path/to/the/file/ -lmysqlclient -o aoe aoe.c |
I installed MySQL-devel-4.0.23-0-i386.rpm earlier. My first attempt at compiling the program gave the error that it couldn't find mysql.h, so I figured (since I installed the client and server from RPMs) that I didn't have the header files. I figured that MySQL-devel-4-0-23-i386.rpm would provide all that I need, but here is what I get now:
Code:
[root@crashbox examples]# rpm -qa MySQL-devel :confused: Thanks again. |
Aha.
Code:
[root@crashbox examples]# rpm -i MySQL-shared-4.0.23-0.i386.rpm |
OK, the problem may have been that there was not actually a table named "examples". I gave it a legitimate name and now it runs without error. However, it does nothing, as though the query "SELECT * FROM games" returned an empty set, although there are over 91 records in the table.
|
Tweaked the code:
Code:
#include <stdio.h> Thanks again for your help, Hko! You'll probably be seeing more posts from me in the near future... :rolleyes: |
All times are GMT -5. The time now is 11:58 AM. |