List:General Discussion« Previous MessageNext Message »
From:Luciano Furtado Date:January 14 2011 11:33pm
Subject:Re: linking to mysql in C
View as plain text  
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

What's the output of mysql_config --libs for you?

On 11-01-08 00:06, Delan Azabani wrote:
> 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'
> /home/delan/cbook/cbook-main.c:160: undefined reference to
> `mysql_free_result'
> cbook-main.o: In function `pageSessions':
> /home/delan/cbook/cbook-main.c:181: undefined reference to
> `mysql_store_result'
> /home/delan/cbook/cbook-main.c:182: undefined reference to `mysql_fetch_row'
> cbook-main.o: In function `main':
> /home/delan/cbook/cbook-main.c:287: undefined reference to `mysql_init'
> /home/delan/cbook/cbook-main.c:289: undefined reference to
> `mysql_real_connect'
> /home/delan/cbook/cbook-main.c:290: undefined reference to `mysql_select_db'
> /home/delan/cbook/cbook-main.c:297: undefined reference to `mysql_close'
> collect2: ld returned 1 exit status
> make: *** [all] Error 1
> 
> I have read the following page already and unfortunately, I am still
> unable to compile it:
> http://dev.mysql.com/doc/refman/5.0/en/c-api-linking-problems.html
> 
> If anyone could help me with this it would be greatly appreciated.
> 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.14 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJNMN1DAAoJENgwSj9ZOOwrZJ0IAMdTAEhptXErCz/4paKGGO+L
mDScIXYvTLNOStrB8zT+SChtMVzgr8V1E8B7MCEz2Ra0XBErvb63JvQ3kLQvmFX8
GBNFFUPRwhyi7pWq+rtj6gRt3Dz0tLAeV6W1Ui/WMJRg5AHopHXm0p2CVWO1vTvI
oiWaaUSCa+k8Sp5YRr551ypKXGcqW5CGGp4utXUyrYRYLNJ4/Ce2VYt/lcDE59Zm
dZXrlXMsiSKf1sTtXkVz5J08GfPIMH9oUnNOKvNrwsI6nf2I7gfCSMBqOAhCAOy1
WGKUJ/gGQ/VjRZI8FdB0dQrJ+DBJwOjBFJvnJAJbvjwATOeqMT1ZQeh6tthUUus=
=Er8U
-----END PGP SIGNATURE-----

Thread
linking to mysql in CDelan Azabani8 Jan
  • Re: linking to mysql in CLuciano Furtado15 Jan
  • Re: linking to mysql in Cwalter harms15 Jan