Sign in to follow this  

setting up mysql in c++

This topic is 4302 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Does anyone know the best way to learn how to use mysql in c++? I searched on google and found a couple api's, but I couldn't really find anything about the api's. I've never used my own MySql server, but for this project I will want to. So if anyone knows of a good place to get started learning how to set up your own MySql server and how to use MySql in c++ could you please let me know. Thank you for your time.

Share this post


Link to post
Share on other sites
Isn't that more based on using MySql with php for a web browser? I already know how to do that, I need to lean how to use it in c++ and how to set up the server. If there is a place on that website I have already been there before and didn't see anything like that. Where exactly would I find something like that on that website.

If anyone else has a link or any helpful information please post.

Thank you for your time.

Share this post


Link to post
Share on other sites
There is no difference between installing mysql for a web server and installing mysql as a standalone RDBMS. If you only want mysql, download the installer and install it.

To setup the server, the manual is your friend.

Once you've done this, download A C++ API (either this one or this one) and enjoy ! (you may still need the MySQL C API - more info here).

HTH,

Share this post


Link to post
Share on other sites
I got MySql installed and working. I can't figure out how to use mysql++. I found a download for it but when I unzipped it I think something went wrong. It wasn't anything like the manuel said. Did I maybe download the wrong thing or something? Does anyone know anything useful about mysql++?

Share this post


Link to post
Share on other sites
Jesus !

I had a look to the build system of mysql++, and it is rather weird.

Ok, so you've downloaded mysql++ (presumaby the tar.gz source distribution). Now, you must extract the file to its own directory. Since it is a tar.gz file, you may need to do this twice (most GUI-based decompressor (7-zip, winzip, winrar, ultimate-zip and so on) are not that stupid, but some may be...). Next, you have to read the README.vc file (if you want to use visual studio) or README.mingw if you plan to use mingw. I suggest you to use Visual Studio - you can download the VS.NET 2003 toolkit for free here.

Follow the steps in your makefile (be aware that you may need gnu make (there is a win32 version available here)

Once you'll be ok, you should have a library, a dll and a bunch of header files. Now, you should be able to create a mysql++ powered program !

HTH,

Share this post


Link to post
Share on other sites
Ok now I am kind of confused. I went to MySql's forum to see if anyone had already posted something like this and I found a thread. The reply to the wuestion was this:

Quote:
Hi.

Try with Dev-Cpp

download pexports-043 (search in google) I don't know the site.

... and execute ...

1. pexports libmysql.dll > libmysql.def
2. dlltool comes with dev-cpp
dlltool -k --input-def libmysql.def --dll-name libmysql.dll --output-lib libmysql.a
3. create a project (with a source code), in project menu->project options->parameters->linker-> add -lmysql
4. compile and link your program
5. a error ocorred

a unrecognized ... mysql_init@4

or something like this.
6. edit limysql.def and add @number in front of the function. Example:
a unrecognized ... mysql_init@4
in libmysql.def
(you find like this)
...
...
mysql_init
...
...
(so)
...
...
mysql_init@4
...
...

save the file. execute dlltool again, and try compile/link,


Bye


This was convenient since I'm using dev-cpp. However I don't know how to use pexports or dlltool. Anyways the part that really has me confused is this is saying that you don't need mysql++ or mysqlapi and you can just use libmysql.dll. Is this true? I mean what exactly do I need mysql++ or mysqlapi for, if you can just use libmysql.dll?

Anyways I read the makefile.mingw and it really didn't explain how to use it. I don't even really know what I'm trying to do with this whole thing. Just from reading the file it seems like its creating a dll, but I thought it was suppose to come with a dll.

If the makefile is even suppose to be making a dll I don't know where I'll find out how to use the dll its making. And if it comes with a dll I didn't find it anywhere in the file and I still don't know how to use that dll either.

So I'd really appreciate it if someone could tell me why I need the mysql++ or mysqlapi when some people say I can use the libmysql.dll, what I do with the makefile.mingw if I need to use mysql++, and what I do after I the makefile.mingw? I know I'm asking for a lot, but I wouldn't be asking if I hadn't looked all over the place and found nothing. Thank you for your time so far.

Share this post


Link to post
Share on other sites
It seems I didn't understand you in the first place. I saw C++, mysql, so I junmped into and said 'hey, give a try to these C++ API wrappers for mysql'. This is obviously not a good idea :)

Of course, the simple way if the use the C API. Once you installed mysql, you should have anything needed to make a program that will work with mysql. Again, have a look at mysql C API for more informations.

Quoting this page:
Quote:
Many of the clients in the MySQL source distribution are written in C. If you are looking for examples that demonstrate how to use the C API, take a look at these clients. You can find these in the clients directory in the MySQL source distribution.


The only thing you have to do is to setup your compiler in order to be able to use the provided library - but I'll assume that you know how to do it, because I don't want to download and install mysql+devcpp [smile]

Regards,

Share this post


Link to post
Share on other sites
hmm. Thats kind of exactly what my problem was from the start. I thought you meant that I needed a wraper to use MySql, so I went to download that. I found those instructions for how to get it to work with dev-cpp but I don't know how to use the pexports or the dlltool. If you know naything about either fo those I'd appreciate if you could tell me about them. Thank you for the help so far.

Share this post


Link to post
Share on other sites
Sorry for the double post but I figured out how to make libmysql.a and I linked that and everything worked fine. But I still don't know how to use any of the MySql commands from within c++. Is that what I need the wrapper for? If I still need the wrapper, can anyone say what I have to do to use the make.mingw? Thank you for your time.

Share this post


Link to post
Share on other sites

This topic is 4302 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this