Hi,

does someone know nice, clean tutorial with links for all headers and libraries for connection to MySQL database? I'm searching for something good for about week now, but I've still found only some rly rly rly retarded posts, without any libraries for donwload or something, just code, i've tried mysqlconnector for c++ but it's not working with visual studio 2010, I need some updated and tested tutorial that is working with visual studio 2010, I've tried MySQL connector, mysql++ and sql api, I don't knoww why, but I've got errors with every thing (mysql connector is not working with vs2010, I have found topic about somewhere, sqlapi is giving me errors from headers - wtf?! etc)

Thanks!

Best Regards, SEnergy!

mysql++ works with VC++ 2010. Must be something you are doing incorrectly. Post some code so that we can see what you are doing.

Edited 5 Years Ago by Ancient Dragon: n/a

#include "stdafx.h"
#include <mysql++.h>
#include <stdlib.h>

using namespace std;
using namespace mysqlpp;

int main()
{
	try
	{
		Connection conn(false);
		conn.connect("logon", "localhost", "root", "pw");
		Query query = conn.query();
	}
	catch (BadQuery er)
	{
		cerr << "Error: " << er.what() << endl;
		return -1;
	}
	catch (const BadConversion& er)
	{
		cerr << "Conversion error: " << er.what() << endl << "\tretrieved data size: " << er.retrieved << ", actual size: " << er.actual_size << endl;
		return -1;
	}
	catch (const Exception& er)
	{
		cerr << "Error: " << er.what() << endl;
		return -1;
	}
	return EXIT_SUCCESS;
}

errors:

1>------ Build started: Project: TestMySQL, Configuration: Debug Win32 ------
1>  TestMySQL.cpp
1>TestMySQL.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall mysqlpp::BadQuery::~BadQuery(void)" (__imp_??1BadQuery@mysqlpp@@UAE@XZ) referenced in function __catch$_main$0
1>TestMySQL.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual char const * __thiscall mysqlpp::Exception::what(void)const " (__imp_?what@Exception@mysqlpp@@UBEPBDXZ) referenced in function __catch$_main$0
1>TestMySQL.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall mysqlpp::Connection::~Connection(void)" (__imp_??1Connection@mysqlpp@@UAE@XZ) referenced in function _main
1>TestMySQL.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall mysqlpp::Query::`vbase destructor'(void)" (__imp_??_DQuery@mysqlpp@@QAEXXZ) referenced in function _main
1>TestMySQL.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class mysqlpp::Query __thiscall mysqlpp::Connection::query(char const *)" (__imp_?query@Connection@mysqlpp@@QAE?AVQuery@2@PBD@Z) referenced in function _main
1>TestMySQL.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual bool __thiscall mysqlpp::Connection::connect(char const *,char const *,char const *,char const *,unsigned int)" (__imp_?connect@Connection@mysqlpp@@UAE_NPBD000I@Z) referenced in function _main
1>TestMySQL.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall mysqlpp::Connection::Connection(bool)" (__imp_??0Connection@mysqlpp@@QAE@_N@Z) referenced in function _main

Edited 5 Years Ago by senergy: n/a

From the looks of those error messages it appears you failed to link with the mysql libraries. Look closely at the tutorials, such as this one, and it will show you how you need to link. That tutorial gives you the makefile you need if you use g++ compiler. For other compilers just link with the two libraries that are mentioned in the makefile (mysqlpp and mysqlclient)

From the looks of those error messages it appears you failed to link with the mysql libraries. Look closely at the tutorials, such as this one, and it will show you how you need to link. That tutorial gives you the makefile you need if you use g++ compiler. For other compilers just link with the two libraries that are mentioned in the makefile (mysqlpp and mysqlclient)

well, in lib folder of mysql++ I have only some headers, and I'm not sure if I've downloaded right file, plus that tutorial is for linux, or?

yes, I have mysql installed, I was using it like 1/2 year ago when I was scripting for World of Warcraft

edit: I found it
edit2: there is only mysqlclient, where can I find mysqlpp ?

Edited 5 Years Ago by senergy: n/a

mysqlpp is created when you compile the MySQL++ library files (yes, you have to compile them yourself). If you are using VC++ 2010 Express then you will have to run the 32-bit version of mysql database server, not the 64-bit version because the c libraries are different. vc++ 2010 express can not link with 64-bit libraries.

Edited 5 Years Ago by Ancient Dragon: n/a

This article has been dead for over six months. Start a new discussion instead.