C++ and mysql connectivity

guys i want to make a simple program connected with mysql. i had searched many topics related to it, but still having problems. im beginner in c++ so send me step by step solution. please help :(
errors are

24:1 C:\Dev-Cpp\include\config-win.h [Warning] "_WIN32_WINNT" redefined
20:1 C:\Dev-Cpp\include\windef.h [Warning] this is the location of the previous definition
111:1 C:\Dev-Cpp\include\config-win.h [Warning] "S_IRWXU" redefined 601 C:\Dev-Cpp\include\math.h `double rint(double)' previously defined here

1
2
3
4
5
6
7
8
9
10
11
12
13
#include<iostream>
#include<conio.h>
#include "windows.h"
#include <my_global.h>
#include <mysql.h>

using namespace std;
int main()
{
     printf("MySQL client version: %s\n", mysql_get_client_info());
    getch();
    return 0;
}
Well, let's begin.

1. What is this IDE ? Deprecated.
First, I see in the paths given that you are using Dev-C++. You should use something else as Dev-C++ is deprecated and no more developped since a while. Instead, you should first download TDM/MinGW. It is a derivation of the MinGW compiler by TDM so there will be few changes. You can download it from here : http://tdm-gcc.tdragon.net/download

Then, you can download the code::Blocks IDE. Simply type CodeBlocks on Google and you will find everything. If you have the choice, then choose to download binaries instead of the sourcecode. As you say to be a beginner, I don't think that you will be able to build it yourself. However, if you want to to it, I can tell you how we do as I have already done it myself.
Code::Blocks will normally, once installed, detect your installation of MinGW if you put it in the default path. And if you are using Dev-C++ project files, know that code::Blocks can import them. Code::Blocks is a nice IDE and if you take the nightly builds (see http://forums.codeblocks.org/index.php/topic,3232.0.html) you will have the last tools that I really like.

If you don't want to completely switch IDEs, then consider using wxDev-C++ (see http://wxdsgn.sourceforge.net/?q=node/4).

You must be wondering why I tell you that. Well the compiler that comes with Dev-C++ is quite old now and maybe the warnings you get are due to this old compiler.

2. You just get some warnings

As far as I can see (Even if I have glasses), you just get warnings.
Most of them come from Windows headers. Also consider not to use <conio.h> wich is a non-standard header. If you are looking for a way to keep the console open at the end of your program, Dev-C++ must have this option as I used it when I began C++ with dev-C++. CodeBlocks also have such an option. If you want a solution that does not involve the IDE or just to learn how you could do this by yourself, then read this wonderful thread, where you will find so much techniques that I personnally still use where I can't be using CodeBlock's option for any reason. Here is the thread : http://www.cplusplus.com/forum/beginner/1988/

Anyway, those warnings seem to come from headers that define several times the same symbols. In other words, it is like if you did something like :
1
2
3
#define A
// ...Some code...
#define A 

Your compiler is not dumb and has seen it and it just wants to warn you, thinking that it is you who wrote it because it is a bad practice and some compilers simply make of it an error.

3. Other things

These are other things. They are not critical problems, just things you should consider to avoid taking bad habits :
- #include<iostream> should be #include <iostream>. Even if the compiler has understood what you mean, just know that there are still some compilers that make of it an error.


That's all I have to say. If you have any questions about anything in this post, or out of this post, then just reply, I will try to answer.
PS: Does your program compile ? Does it work as expected ?

PS2: You are not forced to change your IDEand compiler, it is just some advice.

PS3: The warnings you get don't come from MySQL, they come from some other headers.
thanks for help.
nice
Topic archived. No new replies allowed.