LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-07-2004, 01:29 AM   #1
toships
Member
 
Registered: Feb 2004
Posts: 30

Rep: Reputation: 15
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.
 
Old 04-07-2004, 06:46 AM   #2
worldmagic
Member
 
Registered: Oct 2003
Location: Europe/Sweden
Distribution: RedHat
Posts: 78

Rep: Reputation: 15
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
 
Old 04-07-2004, 06:49 AM   #3
worldmagic
Member
 
Registered: Oct 2003
Location: Europe/Sweden
Distribution: RedHat
Posts: 78

Rep: Reputation: 15
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.
 
Old 04-08-2004, 11:29 PM   #4
toships
Member
 
Registered: Feb 2004
Posts: 30

Original Poster
Rep: Reputation: 15
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 ..
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
MySQL Client API I_AM Linux - Newbie 1 06-27-2005 02:52 AM
MySQL server problem after linking (mysql.sock) ewijaya Linux - General 4 01-19-2004 09:46 AM
msql++ c++ api for mysql nakkaya Linux - Software 0 04-19-2003 03:56 PM
c++ and mysql api nakkaya Programming 4 03-28-2003 11:10 PM
mySQL and C API Problems [RJP]DeanLO Programming 1 11-15-2001 09:16 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:48 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration