Archived

This topic is now archived and is closed to further replies.

PumpkinPieman

MySQL

Recommended Posts

Alright, I have really good background with using my sql in web biased languages. But for some reason I can''t find the api for handling MySQL. I went to the website but I have no idea which one to download, and what to do with it. Anyone here dealt with MySQL through C++, that could help me out? Also, any type of tutorials, I searched GameDev, but didn''t find anything of relevence.

Share this post


Link to post
Share on other sites
If you are in Windows and download/install the mysql package from here then you should already have a /include and a /lib dir that you need to add to your project. All the basic mysql stuff should be there.

-------
Andrew
PlaneShift - A MMORPG in development.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Official documentation of the C API.
http://www.mysql.com/doc/en/C.html

A nice tutorial to get started:
http://www.informit.com/isapi/product_id~{506B247F-BD8F-4D9C-BD62-FE736E57BD7B}/session_id~{1D714069-D6B2-435E-B34E-21E873022053}/content/index.asp

You might want to check out Mysql++ which is a nice C++ wrapper of the C API library, though I wrote my own because I needed something easy to use, and being able to use features that MySQL doesn''t have.

Share this post


Link to post
Share on other sites
quote:
Original post by PumpkinPieman
I still don''t get how I can include them to my program, I really havn''t worked much with including libs.


It depends on your IDE. Usually there should be something in project settings like "Additional Libraries" that you can add in the dir where the MySQL libraries are located. Similar for the includes, there should be something like "Additional Dirs to search for includes" that you can add in the path to the MySQL include files. Read up on your IDE docs on where these exact settings are.



-------
Andrew
PlaneShift - A MMORPG in development.

Share this post


Link to post
Share on other sites
Well my IDE is VC++.net, I just added the lib by right clicking on the project and adding an existing file. But I don't think that worked. :?

I tried to follow the example they had where they added the lib file, then included mysql.h, but it kept on telling me it couldn't find the header. Although, they're example didn't have it in the dir either.

[edited by - PumpkinPieman on November 15, 2003 5:25:45 PM]

Share this post


Link to post
Share on other sites
Select Tools->Options. Under "Projects" you'll find a tab "VC++ Directories". Here you can specify in which dirs the compiler/linker will look for various files, including (no pun intended) include and library files.

-Nik

EDIT:
After sorting that out, set the project's linker option "Additional Dependencies" to whatever libs you need.



[edited by - Nik02 on November 15, 2003 5:52:32 PM]

Share this post


Link to post
Share on other sites
Hmm, I think I'll get it some time. It's still really confusing.

There is a tutorial here http://www.cpp-home.com/tutorial.php?22_1 But for some reason I can't seem to find the file he is talking about, or atleast it doesn't contain a mysql++.lib

[edited by - PumpkinPieman on November 15, 2003 9:18:36 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by PumpkinPieman
There is a tutorial here http://www.cpp-home.com/tutorial.php?22_1 But for some reason I can''t seem to find the file he is talking about, or atleast it doesn''t contain a mysql++.lib
Now you are mixing up two different APIs. There is the plain standard MySQL C API distributed with the server, and then there is a more obscure MySQL++ API. Even though the latter is supposed to be easier to use in C++, in my opinion the former is simpler. Stick with either.

Share this post


Link to post
Share on other sites
quote:
Original post by PumpkinPieman
Yeah I don''t know which is which now. What should I use? If I use the MYSQL++ version, which I probally will. How do I do this step. "Click the Link tab and type in mysql++.lib into the Library text-box." in .net.
I have not use .NET, but in VC++ 6.0, you do it in Project Settings->Link->Object/library modules (add to the list). I think/hope it is about the same in .NET.

I am not sure if I recommend using Mysql++. It uses very advanced C++ to do its magic, and it requires that you have a pretty good understanding of C++ and programming in general. The C API is clear and straight forward, although more typing is required. I am not sure which is better in your case, but I''ve experienced Mysql++ to be a pain in the ass.

Share this post


Link to post
Share on other sites