Compiling a GTK program, that uses libraries MySql (gcc complier)
Posted by: Fabrizio Lo Verde
Date: April 12, 2012 05:12AM

Compiling a GTK program, that uses libraries MySql (gcc complier)

Hi all, I wanted to submit a problem that happened to me recently when I use the GTK libraries.

My intention was to create a GUI in C (using GTK) to interact with a MySQL database (using the libraries provided by mysql.com).

We place now that I typed the command on Linux shell (Ubuntu 11.40):

gcc -Wall -g main.c -o main `mysql_config --cflags --libs` `pkg-config --cflags --libs gtk+-2.0`

Unfortunately known that the compiler can not link the MySQL libraries, thus giving me these errors:

main.c: 14:1: error: unknown type name 'MYSQL'
main.c: 16:3: error: unknown type name 'MYSQL'
main.c: 16:3: warning: implicit declaration of function 'mysql_init' [-Wimplicit-function-declaration]
main.c: 16:29: warning: initialization Makes pointer from integer without a cast [enabled by default]
main.c: 19:5: warning: implicit declaration of function 'mysql_real_connect' [-Wimplicit-function-declaration]
main.c: 21:7: warning: implicit declaration of function 'mysql_close' [-Wimplicit-function-declaration]
main.c: 25:5: warning: implicit declaration of function 'mysql_select_db' [-Wimplicit-function-declaration]

Honestly, are not very experienced in using the GCC compiler, so if any of you could help me out, I would be very grateful! :)

PS: safe place for you also what the compiler in verbose mode printed on the screen:

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-linux-gnu/4.6.1/lto-wrapper
Target: i686-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.1-9ubuntu3' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++,go --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-plugin --enable-objc-gc --enable-targets=all --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=i686-linux-gnu --host=i686-linux-gnu --target=i686-linux-gnu
Thread model: posix
gcc version 4.6.1 (Ubuntu/Linaro 4.6.1-9ubuntu3) 
COLLECT_GCC_OPTIONS='-Wall' '-g' '-v' '-I' '/usr/include/mysql' '-D' 'BIG_JOINS=1' '-fno-strict-aliasing' '-D' 'UNIV_LINUX' '-D' 'UNIV_LINUX' '-rdynamic' '-L/usr/lib/mysql' '-pthread' '-I' '/usr/include/gtk-2.0' '-I' '/usr/lib/i386-linux-gnu/gtk-2.0/include' '-I' '/usr/include/atk-1.0' '-I' '/usr/include/cairo' '-I' '/usr/include/gdk-pixbuf-2.0' '-I' '/usr/include/pango-1.0' '-I' '/usr/include/gio-unix-2.0/' '-I' '/usr/include/glib-2.0' '-I' '/usr/lib/i386-linux-gnu/glib-2.0/include' '-I' '/usr/include/pixman-1' '-I' '/usr/include/freetype2' '-I' '/usr/include/libpng12' '-pthread' '-mtune=generic' '-march=i686'
/usr/lib/gcc/i686-linux-gnu/4.6.1/cc1 -quiet -v -I /usr/include/mysql -I /usr/include/gtk-2.0 -I /usr/lib/i386-linux-gnu/gtk-2.0/include -I /usr/include/atk-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/pango-1.0 -I /usr/include/gio-unix-2.0/ -I /usr/include/glib-2.0 -I /usr/lib/i386-linux-gnu/glib-2.0/include -I /usr/include/pixman-1 -I /usr/include/freetype2 -I /usr/include/libpng12 -imultilib . -imultiarch i386-linux-gnu -D_REENTRANT -D BIG_JOINS=1 -D UNIV_LINUX -D UNIV_LINUX main.c -quiet -dumpbase main.c -mtune=generic -march=i686 -auxbase main -g -Wall -version -fno-strict-aliasing -fstack-protector -o /tmp/ccBDxZjT.s
GNU C (Ubuntu/Linaro 4.6.1-9ubuntu3) version 4.6.1 (i686-linux-gnu)
   compiled by GNU C version 4.6.1, GMP version 5.0.1, MPFR version 3.0.1-p3, MPC version 0.9
GGC heuristics: --param ggc-min-expand=83 --param ggc-min-heapsize=99869
ignoring nonexistent directory "/usr/local/include/i386-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc/i686-linux-gnu/4.6.1/../../../../i686-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/include/mysql
/usr/include/gtk-2.0
/usr/lib/i386-linux-gnu/gtk-2.0/include
/usr/include/atk-1.0
/usr/include/cairo
/usr/include/gdk-pixbuf-2.0
/usr/include/pango-1.0
/usr/include/gio-unix-2.0/
/usr/include/glib-2.0
/usr/lib/i386-linux-gnu/glib-2.0/include
/usr/include/pixman-1
/usr/include/freetype2
/usr/include/libpng12
/usr/lib/gcc/i686-linux-gnu/4.6.1/include
/usr/local/include
/usr/lib/gcc/i686-linux-gnu/4.6.1/include-fixed
/usr/include/i386-linux-gnu
/usr/include
End of search list.
GNU C (Ubuntu/Linaro 4.6.1-9ubuntu3) version 4.6.1 (i686-linux-gnu)
   compiled by GNU C version 4.6.1, GMP version 5.0.1, MPFR version 3.0.1-p3, MPC version 0.9
GGC heuristics: --param ggc-min-expand=83 --param ggc-min-heapsize=99869
Compiler executable checksum: 4563c158c7f73de3aa3de4c02c58d3f9

Options: ReplyQuote


Subject
Views
Written By
Posted
Compiling a GTK program, that uses libraries MySql (gcc complier)
2574
April 12, 2012 05:12AM


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.