Linking error
Posted by: kyi tun
Date: May 27, 2011 02:59AM

Hi I'm developing CGI which is written in C and trying to use Mysql.
When I try to use it, I got those undefined reference errors for symbols that start with mysql_, such as those shown here:

/tmp/ccFKsdPa.o: In function `main':
/tmp/ccFKsdPa.o(.text+0xb): undefined reference to `mysql_init'
/tmp/ccFKsdPa.o(.text+0x31): undefined reference to `mysql_real_connect'
/tmp/ccFKsdPa.o(.text+0x57): undefined reference to `mysql_real_connect'
/tmp/ccFKsdPa.o(.text+0x69): undefined reference to `mysql_error'
/tmp/ccFKsdPa.o(.text+0x9a): undefined reference to `mysql_close'

So I write some sample code and I can run well when I use my program with this line
gcc -o saveUser $(mysql_config --cflags) saveUser.c $(mysql_config --libs)
It works well.

So next step, I try to put my coding in CGI.
I still got those undefined reference again.
Here is my Makefile.basic

CC=/usr/bin/gcc
#CC=powerpc-linux-gcc
CP=/usr/bin/cp
CFLAGS = -g -Wall $(mysql_config --cflags) $(mysql_config --libs)

www=/var/www
htdocs=/htdocs
cgi_bin=/cgi-bin
config=/etc/apache2/sites-available/default

What should I do ? Where it goes wrong ? Is my linking in my Makefile.basic is correct ? Help me please. I have been searching on the internet for a week but still can't get the solution.
Thanks a lot !!!

Options: ReplyQuote


Subject
Views
Written By
Posted
Linking error
1032
May 27, 2011 02:59AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.