MySQL Forums
Forum List  »  Connector/C++

C++ & MySQL - I NEED URGENT HELP
Posted by: Paulo Gnutelli
Date: September 15, 2011 04:02AM

Hi all,

I use MySQL with Java for years, and it's all straightforward and easy.
Now a client ask me to develop a very simple application, but he impose the use of C++ with MySQL, because he's developers are all C++ experts, but they don't have any skills with any DBMS (they don't even know SQL basics).

In the beginning I've tried to run examples that i found by googling, such as:

http://dev.mysql.com/doc/refman/5.6/en/connector-cpp-examples-complete-example-1.html

http://dev.mysql.com/doc/refman/5.6/en/connector-cpp-examples-complete-example-2.html

... and ...

http://blog.ulf-wendel.de/?p=215

No one of the three examples work, and I get dozens of errors in both the compile time and link time


So, my last hope was to wrote a do-nothing program just as follows:

// ====================

// C++ MySQL.cpp : Defines the entry point for the console application.
//

// in the boost libraries site they say "don't use pre-compiled headers
// so, I comment the next line
// #include "stdafx.h"
// however, with pre-compiled headers, the errors are the same


/* Standard C++ includes */
#include <stdlib.h>
#include <iostream>

/*
Include directly the different
headers from cppconn/ and mysql_driver.h + mysql_util.h
(and mysql_connection.h). This will reduce your build time!
*/
#include "mysql_connection.h"

#include <cppconn/driver.h>
#include <cppconn/exception.h>
#include <cppconn/resultset.h>
#include <cppconn/statement.h>

using namespace std;

int main(void)
{
return 0;
}

// ====================

In the settings for the compiler and linker, I indicate the paths to the "includes" and "libraries" properly.

I build and ran the do-nothing program, and I get 3 warnings and 2 errors:

Warning 1:
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'
c:\program files (x86)\mysql\mysql connector c++ 1.1.0\include\sqlstring.h

Warning 2:
warning C4251: 'sql::mysql::MySQL_Connection::proxy' : class 'boost::shared_ptr<T>' needs to have dll-interface to be used by clients of class 'sql::mysql::MySQL_Connection'
C:\Program Files (x86)\MySQL\MySQL Connector C++ 1.1.0\include\mysql_connection.h

Warning 3:
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'
C:\Program Files (x86)\MySQL\MySQL Connector C++ 1.1.0\include\cppconn\exception.h

Error 4:
error C2371: 'int8_t' : redefinition; different basic types
c:\program files (x86)\mysql\mysql connector c++ 1.1.0\include\cppconn\config.h

Error 5:
error C2371: 'int8_t' : redefinition; different basic types
c:\program files (x86)\mysql\mysql connector c++ 1.1.0\include\cppconn\config.h

I use VC++ 2010 Express and MySQL Community Server 5.5.15
Because my OS is Windows 7 64-bit, I've tryed both 32 and 64 bit versions of MySQL Server and MySQL Connector/C++ 1.1.0

I've read in http://dev.mysql.com/downloads/connector/cpp/ that "A better solution is to build your MySQL Connector/C++ libraries from the source code, using the same tools that you use for building your application. This ensures compatibility."

Now the HUGE PROBLEM:

The process of build the connector has a degree of difficulty, that is out of my skills.

Can someone help me? Is there any connector pre-built for VC++ 2010 Express?
Should I use the connector for C instead of C++?
If I use the connector for C instead of C++, the problems persist?

I'll appreciate the help that you can give me. I can't quit the project they ask me.

Thank you in advance

Paulo

Options: ReplyQuote


Subject
Views
Written By
Posted
C++ & MySQL - I NEED URGENT HELP
5228
September 15, 2011 04:02AM
2363
October 26, 2011 09:17AM


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.