Hi,
Since a lot of time, I'm trying to use the API mysql++ in C++, with the ide Code::Blocks over Microsoft Windows XP Home Edition.
When I try to compile, after the linking of mysql_client.lib, I get a hundred of linker errors like that :
variable 'iob_' can't be auto-imported. Please read the ld's documentation about --enable-auto-import.
I tried to add --enable-runtime-pseudo-relloc in the linker options as someone told me in the mysql++ mailing list, it changes nothing.
Finally, here's the simple code I try to compile (an example that comes with mysql++, that's why I kept the copyright at first :
/*
Copyright (C) 2005 Simax
Connexion et Execution d'une requête en C++ console (VC8 - 2005 Express)
cette source utilise l'API MySQL version 5.x
j'ai placé le contenu des fichiers d'en-tête de l'API à l'adresse :
http://www.simax-server.info/api/API_MODIF_MYSQL_5.RAR
NOTE : j'ai modifiée l'API pour qu'elle puisse être utilisée sous Visual Studio 2005 Express
et je sais pas comment peuvent réagir les autres compilateurs
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
#include <mysql.h>
#include <iostream>
using namespace std;
#pragma comment(lib, "libmysql.lib") // libmysql.dll doit etre dans le meme rep.
int main(void)
{
MYSQL mysql;
const char *host = "127.0.0.1"; // Adresse du serveur MySQL
const char *user = "root"; // Nom d'utilisateur
const char *pass = ""; // Mot de passe
const char *db = "lapage2"; // Base de donnée
const char *query = "SELECT * FROM enligne"; // Requête à executer
unsigned int num_fields;
unsigned int num_rows;
MYSQL_RES *result;
system("cls");
cout << "\nSimax MTGO Mysql Connection\n---------------------------------------------\n\n";
cout << "Establishing Remote connection...........";
mysql_init(&mysql);
mysql_options(&mysql,MYSQL_READ_DEFAULT_GROUP,"main");
if (!mysql_real_connect(&mysql,host,"root","","lapage2",0,NULL,0)) //connexion
{
cout << "[Error !]\n\n";
system("pause");
return (0);
}
cout << "[Connected @ "; cout << &mysql; cout << "]\n";
cout << "Sending Request..........................";
if (mysql_query(&mysql,query))
{
cout << "[Error !]\n\n";
system("pause");
return(0);
}
else // requete OK
{
cout << "[Sended]\n";
result = mysql_store_result(&mysql); // enregistrement du résultat
cout << "Result...................................";
if (result)
{
num_fields = mysql_num_fields(result); // champs trouvés
cout << "[";cout << num_fields;cout << " Field(s) founded for query]\n\n";
system("pause");
}
else
{
if(mysql_field_count(&mysql) == 0) // Pas de champs a renvoyer
{
num_rows = mysql_affected_rows(&mysql);
cout << "[no fields or bad SELECT request !]";
system("pause");
}
else // Erreur inconnue
{
cout << "[BAD REQUEST !]";
system("pause");
}
}
}
mysql_close(&mysql); // Fermeture de la connexion
return(0);
}
I know this code is done to be used on Visual C++ Express Edition, but I get the same mistake with this :
#include <stdio.h>
#include <winsock.h>
#include <iostream.h>
#include "mysql/include/mysql.h"
int main(int argc, char *argv[])
{
MYSQL mysql;
mysql_init(&mysql);
mysql_options(&mysql,MYSQL_READ_DEFAULT_GROUP,"testMySQL");
if (!mysql_real_connect(&mysql,"localhost","root","","lapage",0,NULL,0))
{
cout << "Connexion impossible!";
}
else
{
cout << "Connexion réussie!";
}
cout << "Bonjour!";
int y;
scanf("%ld", y);
return 0;
}
and I'm sure this is not a directory/include problem, I corrected all of them by editing files concerned.
Thanks!
Ok, I think this time the Nightly build is installed : the interface is changed and there's a new tab in the build options.
I tried to compile my code, I get a popup telling me :
"It seems that this project has not been build yet. Do you want to build it now?"
Of course I answer yes but the same popup reopen, again and again, until I click on "Cancel", and my program doesn't launch. This problem has nothing to see with mysql because I have it with all my old c::b project... and even with this code :
#include <iostream>
int main()
{
printf("Hello world");
}
And when I click on "Rebuild" :
(http://la-page.qc.ca/cb.PNG)
Thanks again for your patience :)