C++ MySQL Connector error while compiling

Hi,

I'm getting those annoying errors while compiling test program for connect to mysql DB

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
1>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\sqlstring.h(23): warning C4251: 'sql::SQLString::realStr' : class 'std::basic_string<_Elem,_Traits,_Ax>' needs to have dll-interface to be used by clients of class 'sql::SQLString'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Ax=std::allocator<char>
1>          ]
1>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\cppconn\exception.h(59): warning C4251: 'sql::SQLException::sql_state' : class 'std::basic_string<_Elem,_Traits,_Ax>' needs to have dll-interface to be used by clients of class 'sql::SQLException'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Ax=std::allocator<char>
1>          ]
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cppconn\config.h(60): error C2371: 'int8_t' : redefinition; different basic types
1>          c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\stdint.h(17) : see declaration of 'int8_t'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cppconn\config.h(60): error C2371: 'int8_t' : redefinition; different basic types
1>          c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\stdint.h(17) : see declaration of 'int8_t'


source code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include "stdafx.h"

#include <iostream>
#include <sstream>
#include <cstdlib>
#include <string>
using namespace std;

#include "cppconn\driver.h"
#include "cppconn\exception.h"
#include "cppconn\resultset.h"
#include "cppconn\statement.h"

#pragma comment(lib, "mysqlcppconn.lib")

const string server = "tcp://sql09.freemysql.net:3306";
const string username = "senergy";
const string password = "****"; // :)

sql::Driver *driver;
sql::Connection *dbConn;
sql::Statement *stmt;
sql::ResultSet *res;

int main()
{
	try
	{
		driver = get_driver_instance();
	}
	catch(sql::SQLException e)
	{
		cout << "Couldn't get database driver: " << e.what() << endl;
		system("pause");
		exit(1);
	}
	try
	{
		dbConn = driver->connect(server, username, password);
	}
	catch(sql::SQLException e)
	{
		cout << "Couldn't connect to database: " << e.what() << endl;
		system("pause");
		exit(1);
	}
	stmt = dbConn->createStatement();
	try
	{
		stmt->execute("USE mysql");
		res = stmt->executeQuery("show tables");
	}
	catch(sql::SQLException e)
	{
		cout << "SQL error. Error message: " << e.what() << endl;
		system("pause");
		exit(1);
	}
	while(res->next())
	{
		cout << res->getString("login") << endl;
		cout << res->getInt("gm") << endl;
	}
}


I googled around and found that one person had this problem too, but nobody helped him, so I hope I will have more luck :)

I found tutorial for this on internet, I'm using boost and C++ MySQL Connector, compiling in Microsoft Visual Studio 2010 express, any suggestions?
Topic archived. No new replies allowed.