Bug #67356 Visual Studio 2010 compiler errors in Connector/C++
Submitted: 24 Oct 2012 11:20 Modified: 27 Mar 2013 14:22
Reporter: Jonathan Higgins Email Updates:
Status: No Feedback Impact on me:
None 
Category:Connector / C++ Severity:S2 (Serious)
Version:1.1.1 OS:Microsoft Windows (Win7 x64)
Assigned to: CPU Architecture:Any
Tags: Connector/C++, CPP Connector, visual studio 2010

[24 Oct 2012 11:20] Jonathan Higgins
Description:
I ran into a problem compiling the CPP Connector with Visual Studio 2010 this morning (version 1.1.1 and MySQL 5.5.28).  There were many compiler errors related to conflicts with the stdint.h header that is provided with Visual Studio 2010.  

How to repeat:
Attempt to compile it with Visual Studio 2010 SP1.

Suggested fix:
To resolve the issue, and get the compile to work, I did the following:

1) Comment out all code in file config.h
2) Modify native_resultset_wrapper.h, native_connection_wrapper.h, and native_statement_wrapper.h as follows:

//#include <config.h> 		// file is now empty so remove the include
#include <boost/cstdint.hpp>	// CPP Conenctor is already dependent on boost and boost does it right
#include <boost/noncopyable.hpp>
//#ifdef HAVE_STDINT_H		// no longer needed
//#include <stdint.h>		// no longer needed
//#endif			// no longer needed

Additionally, you can get rid of the compiler warnings related to exporting std::string using some macro magic.  For example:

#define __MYPROJECT_EXPORT_BASICSTRING(type,name)\
			__MYPROJECT_EXPORT_ALLOCATOR(type,name##Allocator);\
			__MYPROJECT_EXPORT_TEMPLATE(std::basic_string,type,name)

#define __MYPROJECT_EXPORT_STRING(name)\
            __LOGBOOK_EXPORT_BASICSTRING(char,charstring);

#define __MYPROJECT_EXPORT_WSTRING(name)\
            __MYPROJECT_EXPORT_BASICSTRING(wchar_t,wcharstring);

// call it
__MYPROJECT_EXPORT_STRING(something)
[24 Oct 2012 11:38] Jonathan Higgins
Missed one step in my write up.  config.h also needs the #include <boost/cstdint.hpp> include (that is the only line in the file).
[27 Feb 2013 14:22] MySQL Verification Team
Thank you for the bug report. Please try version 1.1.2 and if the issue continues try the suggestion to build the Connector from source as commented at http://dev.mysql.com/downloads/connector/cpp/ . Thanks.
[28 Mar 2013 1:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".