2
votes

When I compile code that includes Connector/C++ headers, I get the following errors:

c:\qt\2010.03\mingw\bin../lib/gcc/mingw32/4.4.0/../../../../include/stdint.h:27: error: 'int8_t' has a previous declaration as 'typedef signed char int8_t'

c:\qt\2010.03\mingw\bin../lib/gcc/mingw32/4.4.0/../../../../include/stdint.h:31: error: 'int32_t' has a previous declaration as 'typedef int int32_t'

c:\qt\2010.03\mingw\bin../lib/gcc/mingw32/4.4.0/../../../../include/stdint.h:32: error: 'uint32_t' has a previous declaration as 'typedef unsigned int uint32_t'

Literally all I do is this:

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

Now I can go into the file and comment the lines out that give me errors:

//typedef signed char int8_t;
//typedef int  int32_t;
//typedef unsigned   uint32_t;

It compiles, but when I try to run the mysql code:

sql::Driver *driver;
driver = get_driver_instance();

I get this output

test.exe exited with code -1073741515

Any Ideas?

2
Why no <> around your includes?Brendan Long
Fixed angle brackets. Also, this question used to ask about MySQL++, but from the header names he's clearly talking about Connector/C++ instead. MySQL++ is a completely different library.Warren Young

2 Answers

0
votes

The first thing I would think about doing would be to wrap the offending code in a try / catch, and see if it's throwing an exception you can glean some information from...

0
votes

Quoting from the Connector/C++ wiki:

We are sorry but we cannot formally support other compilers than Microsoft Visual Studio 2003 and above.

My guess as to the cause of your first symptom is that Connector/C++'s platform detection code is checking that it's being built for Windows, and from there assuming you're using Visual C++ which doesn't support stdint.h, so it has typedefs to fill in for that case. Later it does #include stdint.h (perhaps because it also detects that it's being built by g++) and thereby causes your type conflict errors.

I don't know about your other problem, but it's likely something else stemming from the fact that they don't try to support MinGW.

There are several things you can do to fix this:

  1. Port Connector/C++ to MinGW. It's open source, you have the code.

  2. Switch to MySQL++, which does support MinGW out of the box. See README-MinGW.txt in the tarball.

  3. Switch to Visual C++. You can download a limited but functional and free (as in beer) version of it from Microsoft that should be sufficient to use Connector/C++.