Skip to main content

Thread: [ C++ and MySQL ] How to compile ?


code:
#include <iostream> #include <mysql.h>  using namespace std;  int main(int argc, char *argv[]) {     mysql *connection;     connection = mysql_init(null);     mysql_real_connect(connection, "localhost", "root", "password", "test", 0, null, 0);     return 0; }
code:
g++ main.cpp -o main -l/usr/include/mysql-lmysqlclient -i/usr/include/mysql main.cpp: in function ‘int main(int, char**)’: main.cpp:8: error: ‘mysql’ not declared in scope main.cpp:8: error: ‘connection’ not declared in scope
what i'm doing wrong ?

** don't blame me source code and/or commands i've used - i'm learning , stuff comes tutorial.

quote posted the secret view post
code:
#include <iostream>  #include <mysql.h>    using namespace std;    int main(int argc, char *argv[])  {      mysql *connection;      connection = mysql_init(null);      mysql_real_connect(connection, "localhost", "root", "password", "test", 0, null, 0);      return 0;  }
code:
g++ main.cpp -o main -l/usr/include/mysql-lmysqlclient -i/usr/include/mysql  main.cpp: in function ‘int main(int, char**)’:  main.cpp:8: error: ‘mysql’ not declared in scope  main.cpp:8: error: ‘connection’ not declared in scope
what i'm doing wrong ?

** don't blame me source code and/or commands i've used - i'm learning , stuff comes tutorial.
i looked mysql.h , found struct there, typedefed "mysql". guess that's want, not "mysql".


Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk [ C++ and MySQL ] How to compile ?


Ubuntu

Comments

Popular posts from this blog

DHT11 Time out error using v0.4.1library

Sketch upload fails with Java error (___REMOVE___/bin/avrdude)!

Arduino Uno + KTY81/210 temperature sensor