View Full Version : mysql and c++
vintem
June 13th, 2005, 05:41 AM
Hello everyone,
if I'm to acces a mysql database from within a C++ program, I should #include something. What is this something and how can I get this file (or these files) installed?
Is it possible via Synaptic Package Manager?
Thank you very much for your replies.
Sniffer
June 13th, 2005, 07:02 AM
Explain better!!!!!!!!!!!!!!!!!!!
Do you mean Mysql and MySQLCC (Control Center)?? You can check the Ubuntu Guide to know how to install it by Synaptic...
Are you tryng to develop some access program in C++??
vintem
June 13th, 2005, 08:02 AM
Sorry for not being clear.
I want to write a program in C++ that is able to query a table, to add records to this table, etc. The table is in a MySql database.
I know there are some header-files to #include, to get the program working with a mysql database. But I don't know exactly what the header-files are and how I should install them with Synaptic Package Manager.
MysqlCC has nothing to do with it, I suppose, as it is the control center for Mysql.
I hope this is a better explanation of my question. Thanks for replying.
LordHunter317
June 13th, 2005, 08:55 AM
Sorry for not being clear.
I want to write a program in C++ that is able to query a table, to add records to this table, etc. The table is in a MySql database.
I know there are some header-files to #include, to get the program working with a mysql database. But I don't know exactly what the header-files are and how I should install them with Synaptic Package Manager.
MysqlCC has nothing to do with it, I suppose, as it is the control center for Mysql.
I hope this is a better explanation of my question. Thanks for replying.
You need to install libmysqlclient-dev, which will give you the C programming interface.
You may also want to look at http://mysqlcppapi.sourceforge.net/.
Don't use libsqlplus1, as it's unmaintained and not standard C++.
vintem
June 14th, 2005, 07:35 AM
This works. Thanks for your help. I really appreciate it!!!
The only thing I would like to add (for eventual other beginners) is that, when you compile, you should use -I -L and -lmysqlclient options. You also must
#include<mysql.h>
Then, to compile:
g++ -c -I/usr/include/mysql testdb.c
g++ -o testdb testdb.o -L/usr/lib/mysql -lmysqlclient
This worked on my system. The paths may differ of course.
Rabbitbunny
February 25th, 2009, 03:14 PM
This works perfectly under 8.04 Hardy and 8.10 Interpid although the proper package is libmysqlclient15-dev for both.
vBulletin® v3.8.7, Copyright ©2000-2012, vBulletin Solutions, Inc.