views:

394

answers:

3

Have someone ever done this before???

I am trying to use MinGW to compile a program using the MySQL libraries. I keep getting the message that the function 'rint' is redefined. Ok it's true that the function is in both files config-win.h, from MySQL and math.h from the standard library, but both of them are suppose to be libraries with no problems.

After breaking my head a while i tried even this, that wont compile:

#include <iostream>
#include <my_global.h>
#include <mysql.h>
using namespace std;

int main() {
    cout << "Hello World!!!" << endl; // prints Hello World!!!
    return 0;   
}

And this is the command as well as the output i issue for compiling

i586-mingw32msvc-cc -I/usr/include/mysql probando.cpp -w

In file included from /usr/include/mysql/my_global.h:73,
                 from probando.cpp:10:
/usr/include/mysql/config-win.h: In function ‘double rint(double)’:
/usr/include/mysql/config-win.h:229: error: redefinition of ‘double rint(double)’
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/include/math.h:635: error: ‘double rint(double)’ previously defined here

I have tested it both in WindowsXP with MinGW, with the MySQL libraries properly transformed in .a libraries and in Linux (the output is from Linux, pretty much the same than in Windows) with MinGW32.

People... I am running out of options... Any clues?? Has someone worked before with MySQL and MinGW?? May it work with Cygwin??

Thanks in advance if you take the time to answer.

A: 

I don't know the stack in question but my guess would be that somehow math.h is getting double included. Take a look at the math.h file. There should be an include guard somewhere close to the top. Follow the link if you're not familiar with the concept of an include guard. In both places you should include math.h using the include guards.

You might also look for #defines that are specific to Linux; the file may not be included twice on Linux due to a #define somewhere.

As I said, this is just a guess.

Onorio Catenacci
+1  A: 

Also a guess, but it appears as if math.h AND config-win.h have a function called rint, make sure that there aren't two functions with the same names.

BTW, because I am not entirely sure, I'm making this community editable, feel free to edit this post if I am incorrect.

mdec
A: 

Ok I solved it.

The stupid of mine was including the wrong file. To do it in mingw you have to #include and not

Thanks anyway!!!

pabloh84