Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Mysql.h showing compile errors in eclipse
Mysql.h showing compile errors in eclipse [message #990211] Tue, 11 December 2012 12:18 Go to next message
Satheeshkumar C K is currently offline Satheeshkumar C KFriend
Messages: 3
Registered: December 2012
Junior Member
Hai,
I'm trying to use mysql with Eclipse IDE.
I've installed mysql and included the header file in my program.

#include <my_global.h>
#include <mysql.h>


But when I compiled it, it is giving these errors.....

: undefined reference to `mysql_init'
: undefined reference to `mysql_real_connect'
: undefined reference to `mysql_error'
: undefined reference to `mysql_query'
: undefined reference to `mysql_error'
: undefined reference to `mysql_use_result'
: undefined reference to `mysql_fetch_row'
: undefined reference to `mysql_free_result'
: undefined reference to `mysql_close'
collect2: ld returned 1 exit status


When I do Ctrl+Click on any of these functions, the editor correctly opens the header file.
Can I know where to add the libraries, include paths and linker flags of mysql in eclipse.

I'm using redhat enterprise linux 6.1 and Eclipse Juno

Thank you
Re: Mysql.h showing compile errors in eclipse [message #990411 is a reply to message #990211] Wed, 12 December 2012 10:49 Go to previous messageGo to next message
Axel Mueller is currently offline Axel MuellerFriend
Messages: 1973
Registered: July 2009
Senior Member
http://wiki.eclipse.org/CDT/User/FAQ#Adding_C.2FC.2B.2B_External_Libraries

Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Re: Mysql.h showing compile errors in eclipse [message #990550 is a reply to message #990411] Thu, 13 December 2012 05:19 Go to previous messageGo to next message
Satheeshkumar C K is currently offline Satheeshkumar C KFriend
Messages: 3
Registered: December 2012
Junior Member
Hai,
I've given it like this.
1)Under properties->C/C++ Build->Settings->GCC Compiler->Includes
added var/lib/mysql, /usr/lib64/mysql and /usr/include/mysql
2)Under properties->C/C++ Build->Settings->GCC Compiler->Miscellaneous
-c -fmessage-length=0 $(mysql_config --cflags)
3)Under properties->C/C++ Build->Settings->GCC Linker->Libraries->Libraries(-I)
$(mysql_config --libs)
4)3)Under properties->C/C++ Build->Settings->GCC Linker->Libraries->Library search path(-L)
added /usr/include, var/lib/mysql, /usr/lib64/mysql and /usr/include/mysql
5)Under properties->C/C++ Build->Settings->GCC Linker->Miscellaneous
-pthread -lm -lrt

But, I'm still getting error:
gcc: argument to '-l' is missing


I think I'm missing something in the linker.

Thank you
Re: Mysql.h showing compile errors in eclipse [message #990616 is a reply to message #990550] Thu, 13 December 2012 13:01 Go to previous messageGo to next message
Axel Mueller is currently offline Axel MuellerFriend
Messages: 1973
Registered: July 2009
Senior Member
Usage of mysql_config in the command line options is not supported by Eclipse CDT. There is a plugin for pkg-config support.
http://code.google.com/p/pkg-config-support-for-eclipse-cdt/
Perhaps you can this one (or ask the author to help you).


Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Re: Mysql.h showing compile errors in eclipse [message #990751 is a reply to message #990616] Fri, 14 December 2012 05:39 Go to previous message
Satheeshkumar C K is currently offline Satheeshkumar C KFriend
Messages: 3
Registered: December 2012
Junior Member
Hai,
Thanks for your reply.
I've added pkg-config, but I didn't see anything for mysql there.
using terminal, I can compile and link C file as
gcc -o exe $(mysql_config --cflags) main.c $(mysql_config --libs)


But, in eclipse I am not able to link it. I might be doing something wrong.

Thanks
Previous Topic:"C/C++ Remote Application" debug launch configuration issues
Next Topic:CDT (C and C++ addon)
Goto Forum:
  


Current Time: Sat Dec 20 08:55:04 GMT 2014

Powered by FUDForum. Page generated in 0.07375 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software