Показать сообщение отдельно
Старый 04.04.2013, 16:06   #39
Visible
Пользователь
 
Регистрация: 11.07.2010
Сообщений: 56
Сказал(а) спасибо: 16
Поблагодарили 0 раз(а) в 0 сообщениях
Visible На верном пути
Печаль

Создаю пустой проект (VSE 2012).
Копирую в проект папку mysql из исходников мангоса dep\include\mysql
копирую папку lib из dep\lib

создаю cpp

Код:
#include "mysql/my_global.h"
#include "mysql/mysql.h"

#define SERVER "localhost"
#define USER "username"
#define PASSWORD "password"
#define DATABASE "databasename"
 
int main()
{
    MYSQL *connect; // Create a pointer to the MySQL instance
    connect=mysql_init(NULL); // Initialise the instance
    /* This If is irrelevant and you don't need to show it. I kept it in for Fault Testing.*/
    if(!connect)    /* If instance didn't initialize say so and exit with fault.*/
    {
        fprintf(stderr,"MySQL Initialization Failed");
        return 1;
    }
    /* Now we will actually connect to the specific database.*/
 
    connect=mysql_real_connect(connect,SERVER,USER,PASSWORD,DATABASE,0,NULL,0);
    /* Following if statements are unneeded too, but it's worth it to show on your
    first app, so that if your database is empty or the query didn't return anything it
    will at least let you know that the connection to the mysql server was established. */
 
    if(connect){
        printf("Connection Succeeded\n");
    }
    else{
        printf("Connection Failed!\n");
    }
    MYSQL_RES *res_set; /* Create a pointer to recieve the return value.*/
    MYSQL_ROW row;  /* Assign variable for rows. */
    mysql_query(connect,"SELECT * FROM TABLE");
    /* Send a query to the database. */
    unsigned int i = 0; /* Create a counter for the rows */
 
    res_set = mysql_store_result(connect); /* Receive the result and store it in res_set */
 
    unsigned int numrows = mysql_num_rows(res_set); /* Create the count to print all rows */
 
    /* This while is to print all rows and not just the first row found, */
 
    while ((row = mysql_fetch_row(res_set)) != NULL){
        printf("%s\n",row[i] != NULL ?
        row[i] : "NULL"); /* Print the row data */
    }
    mysql_close(connect);   /* Close and shutdown */
    return 0;
}
Получаю ошибки:
Код:
	1	error C1083: Cannot open include file: 'config-win.h': No such file or directory	c:\\consoleapplication1\consoleapplication1\mysql\my_global.h	76	1	ConsoleApplication1
	2	IntelliSense: cannot open source file "config-win.h"	c:\\ConsoleApplication1\ConsoleApplication1\mysql\my_global.h	76	1	ConsoleApplication1
	3	IntelliSense: cannot open source file "my_attribute.h"	c:\\ConsoleApplication1\ConsoleApplication1\mysql\my_global.h	619	1	ConsoleApplication1
	4	IntelliSense: cannot open source file "my_dbug.h"	c:\\ConsoleApplication1\ConsoleApplication1\mysql\my_global.h	655	1	ConsoleApplication1
	5	IntelliSense: identifier "SOCKET_SIZE_TYPE" is undefined	c:\\ConsoleApplication1\ConsoleApplication1\mysql\my_global.h	694	9	ConsoleApplication1
	6	IntelliSense: #error directive: "please add -DSTACK_DIRECTION=1 or -1 to your CPPFLAGS"	c:\\ConsoleApplication1\ConsoleApplication1\mysql\my_global.h	819	2	ConsoleApplication1
	7	IntelliSense: #error directive: Neither int or long is of 4 bytes width	c:\\ConsoleApplication1\ConsoleApplication1\mysql\my_global.h	1004	2	ConsoleApplication1
	8	IntelliSense: identifier "off_t" is undefined	c:\\ConsoleApplication1\ConsoleApplication1\mysql\my_global.h	1074	9	ConsoleApplication1
	9	IntelliSense: invalid combination of type specifiers	c:\\ConsoleApplication1\ConsoleApplication1\mysql\my_global.h	1103	15	ConsoleApplication1
что то в последнее время ничего неполучается(
Visible вне форума   Ответить с цитированием