Salve a tutti. Uso dev-c++ e ho creato un nuovo progetto C per connettermi al mio database mysql. Nelle opzioni del progetto, ho specificato nelle "Cartelle include", l'indirizzo: C:\mysql\include.
Questo il codice:
codice:
#include <mysql.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
MYSQL *connection;
MYSQL *res:
MYSQL *row;
char *host = "localhost";
char *user = "root";
char *pass = "";
char *db = "mysql";
connection = mysql_init (NULL);
if (!mysql_real_connect (connection, host, user, pass, db, 0, NULL, 0))
{
printf ("%s", mysql_error (connection));
exit (0);
}
if (mysql_query (connection, "CREATE TABLE IF NOT EXISTS ctest (id INT UNSIGNED NOT NULL auto_increment, value VARCHAR (20), PRIMARY KEY (id))"))
{
printf ("%s", mysql_error (connection));
exit (0);
}
mysql_free_result (res);
mysql_close (connection);
system("PAUSE");
return 0;
}
Ma mi da vari errori quando tento di compilare, ecco il log:
codice:
Compilatore: Default compiler
Building Makefile: "C:\Dev-Cpp\Makefile.win"
Esecuzione di make...
make.exe -f "C:\Dev-Cpp\Makefile.win" all
gcc.exe -c main.c -o main.o -I"C:/Dev-Cpp/include" -I"C:/mysql/include" -I"C:/mysql/include"
In file included from C:/mysql/include/mysql.h:72,
from main.c:1:
C:/mysql/include/mysql_com.h:183: error: syntax error before "SOCKET"
C:/mysql/include/mysql_com.h:183: warning: no semicolon at end of struct or union
C:/mysql/include/mysql_com.h:222: error: syntax error before '}' token
C:/mysql/include/mysql_com.h:222: warning: data definition has no type or storage class
C:/mysql/include/mysql_com.h:335: error: syntax error before '*' token
C:/mysql/include/mysql_com.h:336: error: syntax error before '*' token
C:/mysql/include/mysql_com.h:337: error: syntax error before '*' token
C:/mysql/include/mysql_com.h:338: error: syntax error before '*' token
C:/mysql/include/mysql_com.h:339: error: syntax error before '*' token
C:/mysql/include/mysql_com.h:340: error: syntax error before '*' token
C:/mysql/include/mysql_com.h:341: error: syntax error before '*' token
C:/mysql/include/mysql_com.h:342: error: syntax error before '*' token
C:/mysql/include/mysql_com.h:345: error: syntax error before '*' token
C:/mysql/include/mysql_com.h:346: error: syntax error before '*' token
C:/mysql/include/mysql_com.h:358: error: syntax error before "s"
In file included from main.c:1:
C:/mysql/include/mysql.h:257: error: syntax error before "NET"
C:/mysql/include/mysql.h:257: warning: no semicolon at end of struct or union
C:/mysql/include/mysql.h:282: error: 'scramble' redeclared as different kind of symbol
C:/mysql/include/mysql_com.h:426: error: previous declaration of 'scramble' was here
C:/mysql/include/mysql.h:282: error: 'scramble' redeclared as different kind of symbol
C:/mysql/include/mysql_com.h:426: error: previous declaration of 'scramble' was here
C:/mysql/include/mysql.h:311: error: syntax error before '}' token
C:/mysql/include/mysql.h:311: warning: data definition has no type or storage class
C:/mysql/include/mysql.h:319: error: syntax error before "MYSQL"
C:/mysql/include/mysql.h:319: warning: no semicolon at end of struct or union
C:/mysql/include/mysql.h:328: error: syntax error before '}' token
C:/mysql/include/mysql.h:328: warning: data definition has no type or storage class
C:/mysql/include/mysql.h:346: error: syntax error before "NET"
C:/mysql/include/mysql.h:346: warning: no semicolon at end of struct or union
C:/mysql/include/mysql.h:352: error: conflicting types for 'last_errno'
C:/mysql/include/mysql_com.h:211: error: previous declaration of 'last_errno' was here
C:/mysql/include/mysql.h:355: error: conflicting types for 'last_error'
C:/mysql/include/mysql_com.h:210: error: previous declaration of 'last_error' was here
C:/mysql/include/mysql.h:356: error: syntax error before '}' token
C:/mysql/include/mysql.h:356: warning: data definition has no type or storage class
C:/mysql/include/mysql.h:404: error: syntax error before '*' token
C:/mysql/include/mysql.h:405: error: syntax error before '*' token
C:/mysql/include/mysql.h:406: error: syntax error before '*' token
C:/mysql/include/mysql.h:407: error: syntax error before '*' token
C:/mysql/include/mysql.h:409: error: syntax error before '*' token
C:/mysql/include/mysql.h:410: error: syntax error before '*' token
C:/mysql/include/mysql.h:411: error: syntax error before '*' token
C:/mysql/include/mysql.h:790: error: syntax error before '*' token
C:/mysql/include/mysql.h:791: error: syntax error before '*' token
C:/mysql/include/mysql.h:794: error: syntax error before '*' token
C:/mysql/include/mysql.h:795: error: syntax error before '*' token
C:/mysql/include/mysql.h:796: error: syntax error before '*' token
C:/mysql/include/mysql.h:799: error: syntax error before '*' token
C:/mysql/include/mysql.h:802: error: syntax error before '*' token
C:/mysql/include/mysql.h:803: error: syntax error before '*' token
C:/mysql/include/mysql.h:804: error: syntax error before '*' token
C:/mysql/include/mysql.h:805: error: syntax error before '*' token
C:/mysql/include/mysql.h:806: error: syntax error before '*' token
C:/mysql/include/mysql.h:807: error: syntax error before '*' token
C:/mysql/include/mysql.h:811: error: syntax error before '*' token
C:/mysql/include/mysql.h:811: error: syntax error before '*' token
C:/mysql/include/mysql.h:811: warning: data definition has no type or storage class
C:/mysql/include/mysql.h:812: error: syntax error before '*' token
C:/mysql/include/mysql.h:812: error: syntax error before '*' token
C:/mysql/include/mysql.h:812: warning: data definition has no type or storage class
C:/mysql/include/mysql.h:813: error: syntax error before '*' token
C:/mysql/include/mysql.h:814: error: syntax error before '*' token
C:/mysql/include/mysql.h:815: error: syntax error before '*' token
C:/mysql/include/mysql.h:816: error: syntax error before '*' token
C:/mysql/include/mysql.h:818: error: syntax error before '*' token
C:/mysql/include/mysql.h:819: error: syntax error before '*' token
C:/mysql/include/mysql.h:820: error: syntax error before '*' token
C:/mysql/include/mysql.h:821: error: syntax error before '*' token
C:/mysql/include/mysql.h:822: error: syntax error before '*' token
C:/mysql/include/mysql.h:823: error: syntax error before '*' token
C:/mysql/include/mysql.h:825: error: syntax error before '*' token
C:/mysql/include/mysql.h:826: error: syntax error before '*' token
C:/mysql/include/mysql.h:827: error: syntax error before '*' token
C:/mysql/include/mysql.h:828: error: syntax error before '*' token
C:/mysql/include/mysql.h:829: error: syntax error before '*' token
C:/mysql/include/mysql.h:830: error: syntax error before '*' token
main.c: In function `main':
main.c:7: error: `connection' undeclared (first use in this function)
main.c:7: error: (Each undeclared identifier is reported only once
main.c:7: error: for each function it appears in.)
main.c:8: error: `res' undeclared (first use in this function)
main.c:8: error: syntax error before ':' token
make.exe: *** [main.o] Error 1
Esecuzione terminata
(ho accorciato un pò il log altrimenti non riuscivo a postare)
Qualche idea?