List:General Discussion« Previous MessageNext Message »
From:walter harms Date:January 15 2011 4:03pm
Subject:Re: linking to mysql in C
View as plain text  
You are missing the libmysqlclient.
I guess the problem is your makefile. make != shell

You CFLAGS should have something like this:
-L/usr/lib/mysql -lmysqlclient

(Actualy it should be LDFLAGS and LOADLIBES)

something like $(shell pkg-config --cflags $(packages) ) should work
further reading: http://www.gnu.org/software/make/manual/make.html#Shell-Function

hope that helps,
re,
 wh

Am 08.01.2011 06:06, schrieb Delan Azabani:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Hi all,
> 
> This is a novice problem I'm having with compiling a C CGI program with
> MySQL on my Gentoo box.
> 
> I have a simple source so far:
> 
> * cbook-main.c: http://pastebin.com/vnT6j1z2
> * cbook-main.h: http://pastebin.com/4BnyWs27
> * Makefile: http://pastebin.com/m973gbjG
> 
> When compiling I receive undefined reference errors:
> 
> delan@delan2 ~/cbook $ make
> make cbook-main
> make[1]: Entering directory `/home/delan/cbook'
> cc -g `pkg-config --cflags libconfuse glib-2.0` `mysql_config --cflags`
> - -c cbook-main.c
> make[1]: Leaving directory `/home/delan/cbook'
> cc `pkg-config --libs libconfuse glib-2.0` `mysql_config --libs` -o
> cbook.cgi cbook-main.o
> cbook-main.o: In function `myerror':
> /home/delan/cbook/cbook-main.c:61: undefined reference to `mysql_error'
> /home/delan/cbook/cbook-main.c:61: undefined reference to `mysql_errno'
> cbook-main.o: In function `myescape':
> /home/delan/cbook/cbook-main.c:67: undefined reference to
> `mysql_real_escape_string'
> cbook-main.o: In function `myquery':
> /home/delan/cbook/cbook-main.c:85: undefined reference to `mysql_query'
> cbook-main.o: In function `createDatabase':
> /home/delan/cbook/cbook-main.c:90: undefined reference to `mysql_select_db'
> cbook-main.o: In function `pageHome':
> /home/delan/cbook/cbook-main.c:144: undefined reference to
> `mysql_store_result'
> /home/delan/cbook/cbook-main.c:146: undefined reference to `mysql_fetch_row'
> /h
Thread
linking to mysql in CDelan Azabani8 Jan
  • Re: linking to mysql in CLuciano Furtado15 Jan
  • Re: linking to mysql in Cwalter harms15 Jan