List:General Discussion« Previous MessageNext Message »
From:Delan Azabani Date:January 8 2011 5:06am
Subject:linking to mysql in C
View as plain text  
-----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'
/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.

- -- 
Thanks and best regards,
Delan Azabani
http://azabani.com/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.16 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJNJ/DQAAoJEAVIdHYYQWqnYTQP/10GHt7lmBjynjTXfypg+EHg
+z0mW3yr0J6TIBYasYdNSPWr2y6LCu1WqM2hP350pxj3ILQwJTZWldL9ZZZZ3uyo
minSTobxcLU7Q2NCq5yJI6nTvW8WbBUlsAuSLiFrJSRSljH7roL4i2hLqrx66GkB
OCwoykznGcWsYKrTnhcszCQ2opK2YVf3T4duImynoYfFsZWP5JYyse5kGBJhXFaR
vUGpbNu59EFRylyDpRkMvQDUv45Y+cBpmruz+OUpit5eoyOxg3aUd9Bdm+FIHnMQ
c5QTz/g8kwfQJ5eOkWZhHfvO8jBLOdPFqkd9vdayw3kZihEXKMHTco8pFQRm/F2q
4w0TPCAaedN+1gspS+1Hon5ADBuz8q0J+LWkiOWcPKj6NL4NXOiQwQd8PZdyNOmM
VhH1/kF4Y5wCKvl/tQJWOjjJO31LOX9Lmdz8cP4sI8opHbJ4K4WPWj31spkFkF7c
NYwr+S6X+BLFvrKcunyIHYe+4btnt57BtMouTyNb8mb59rQFhL7h0LiUPhrzpwxr
wk1byf7Ov0OyVE7b2bc5+bIAf4MnaPVC+TGTezPFLbpx1tE40ZWlBxAjxPFmIuvY
ZjB7Rtyc4+bW2fMiM4GFVQODsvJCB9x/tUNOw7I2jyKQI5pBczkqBxiNqswVM7yE
yc77+eyvX6IgeZ9svzvO
=y9dU
-----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