I want to connect to my MySQL server with C++ from Eclipse. (in Ubuntu 10.10)
I've added all mysql header files for linux in my eclipse project.
I created my source file (mysql1.cpp):
- Code: Select all
/*
* mysql1.cpp
*
* Created on: Mar 21, 2011
* Author: dennis
*/
#include <stdlib.h>
#include <stdio.h>
#include "driver.h"
#include "mysql_driver.h"
#include "mysql_connection.h"
using namespace std;
int main(void)
{
sql::mysql::MySQL_Driver *driver;
driver = sql::mysql::get_driver_instance();
printf("done\n");
return EXIT_SUCCESS;
}
But when I run it I get a error code.
Complete compiling code in Eclipse:
**** Build of configuration Debug for project mysql1 ****
make all
Building file: ../mysql1.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"mysql1.d" -MT"mysql1.d" -o"mysql1.o" "../mysql1.cpp"
Finished building: ../mysql1.cpp
Building target: mysql1
Invoking: GCC C++ Linker
g++ -o"mysql1" ./mysql1.o
./mysql1.o: In function `main':
/home/dennis/Documents/cppWorkspace/workspace1/mysql1/Debug/../mysql1.cpp:21: undefined reference to `sql::mysql::get_driver_instance()'
collect2: ld returned 1 exit status
make: *** [mysql1] Error 1
In the downloaded pack were some files with this names:
libmysqlcppconn.so
libmysqlcppconn.so.5
libmysqlcppconn.so.5.1.1.0
libmysqlcppconn-static.a
But I don't what to do with these.
I hope someone could help me with my MySQL/C++ problem.
Thanks,
Dennis
