views:

195

answers:

2

I need mysql.h for my c++ program.

A: 

Here is the Official MySQL connector for C++, as provided by the MySQL team.

From the link I posted, you can download an installer for your operating system (Windows I suppose since you mentionned cygwin).

I never used Eclipse but whatever the C++ compiler you use, you should be able to specify additional include/lib directories. Here you must add an entry which points to the installed MySQL C++ connector files.

I never had a try with cygwin myself though.

ereOn
Be aware that the MySQL Connector 1.0.5 is sparsely documented. It is based on the Java connector and the JDBC API. If you need documentation, try reviewing the JDBC web pages. Also look at the header files.
Thomas Matthews
yup thx for advice
rupali
+2  A: 

The main reason MySQL isn't already in the Cygwin package repository is that there's little point in running the MySQL server under Cygwin, as that would only slow it down and not provide any compensating benefit.

All you actually need, though, is the C API client library. It's easy enough to build it yourself.

First, download the source code tarball from mysql.com.

Then at a Cygwin prompt, say:

$ tar xvzf /wherever/it/is/mysql-5.1.46.tar.gz
$ cd mysql-5.1.46
$ ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var \
    --infodir=/usr/share/info --mandir=/usr/share/man \ 
    --disable-shared --without-{debug,readline,libedit,server}
$ make
$ make install

That should build and install just the C client library parts, which should let your other code build.

The most critical part of that configure command is the --without-* bit. Without that, it tries to build everything, which didn't work last time I tried it. You can't blame MySQL, Inc, for not patching Cygwin-specific bugs in the server, since you'd want to use the native binaries instead. There's no problem running a client linked to the Cygwin C library against a fully-native server, any more than there is running client and server on two entirely different OSes across a network.

Incidentally, after you get the C library up and running, you might want to look at MySQL++. (Disclaimer: I'm MySQL++'s primary maintainer.)

Warren Young
I will check it..thx for brief explanation...
rupali
<a href=http://www.freeimagehosting.net/image.php?66b678ba98.gif><img src=http://www.freeimagehosting.net/uploads/th.66b678ba98.gif alt="Free Image Hosting by FreeImageHosting.net"></a>m facing this error
rupali
The URL points to an image too small to read. Can't you cut and paste the test of the error instead? Before you post it, ask yourself if it's not a separate question. If it is, post it separately. Then you may want to accept my answer.
Warren Young
thx for reply..i will post the output of screen..please hav a look n suggest
rupali
as u mentioned all commands above after ./configure - checking..checking...I did make and it gives me following msg>>>>>>>>>>>> $ makemake: *** No targets specified and no makefile found. Stop.
rupali
"no makefile found" means the configure step failed. It would have told you why as well.
Warren Young
But there are 2 Makefiles I could see ...Makefile.amMakefile.inWhy this error coming then.. plz suggest
rupali
Makefile.am is input to automake, which produces Makefile.in. Makefile.in is input to the configure script, which only produces Makefile when the script succeeds. Only "Makefile" is a true makefile; the other two are higher-level files that make cannot interpret. So, your configure step isn't working, as I said. Instead of copying the backslashes, fold the entire command onto a single line. The backslashes let a command wrap over multiple lines, which I did only because of Stack Overflow formatting limitations: code blocks are fixed-width.
Warren Young
so i have to run again without backslashes.. will try
rupali
stay in touch.. will be back :)
rupali