linking C api for mysql
Hi all
System info : OS : RH 9.0 MySQL 4.0-18 standard I am trying to compile a very basic c api for mysql. I tried using gcc and linking the libs as follows : ----------- [root@localhost db]# gcc -o mysqldemo mysqldemo.c -I/usr/src/mysql/include -L/usr/mysql/lib -lmysqlclient /tmp/ccU2zuDq.o(.text+0x45): In function `main': : undefined reference to `mysql_connect' collect2: ld returned 1 exit status --------- I also tried using mysql_config : -------- [root@localhost db]# CFG=/usr/src/mysql/bin/mysql_config [root@localhost db]# sh -c "gcc -o mysqldemo `$CFG --cflags` mysqldemo.c `$CFG --libs`" /usr/bin/ld: cannot find -lz collect2: ld returned 1 exit status --------- I am also a bit confused about how to uninstall this mysql version, since there was no make file all I had to do to install it was "./configure". I am pretty sure that I am not using the libraries right. Thanks for any suggesions in advance. -toships. |
mm, theres no function called mysql_connect in the library
$ nm libmysqlclient.so | grep connect U connect@@GLIBC_2.0 000082c0 T my_connect 0000d010 T mysql_manager_connect 00009f20 T mysql_real_connect 0000ac20 t mysql_reconnect |
The later sais that it does not find libz.so .. usaly located in /usr/lib.. add a -L/usr/lib infront of your mysql_config.
|
Hi worldmagic thanks for you replies.
Apparently from mysql-4.0 onwards they have discontinued mysql_connect and are using mysql_real_connect unless some flags are set during configuration. I finally ended up removing all the relevant mysql files form my system and then installing the rpms from my rh cd. It was a pretty lame thing to do .. but I have a working mysql setup without any compilation errors for my c api .. ;) |
All times are GMT -5. The time now is 04:18 PM. |