c++ - #include <mysql.h> 在 Eclipse for C++ 中不起作用 - 如何配置它?

标签 c++ mysql eclipse include

鉴于以下情况:

// Include Header Files
#include <iostream>
#include <cstdio>
#include <cstdlib>

// For MySQL Connection
#include <mysql.h>

using namespace std;

// Defining Constant Variables
#define SERVER "localhost"
#define USER "root"
#define PASSWORD "password"
#define DATABASE "test"

int main()
{
    MYSQL *connect;
    connect = mysql_init(NULL);

    if (!connect)
    {
        cout << "Mysql Initialization Failed";
        return 1;
    }

    connect = mysql_real_connect(connect, SERVER, USER, PASSWORD, DATABASE, 0,NULL,0);

    if (connect)
    {
        cout << "Connection Succeeded\n";
    }
    else
    {
        cout << "Connection Failed\n";
    }

    MYSQL_RES *res_set;
    MYSQL_ROW row;

    // Replace MySQL query with your query

    mysql_query (connect,"show tables");

    unsigned int i=0;

    res_set=mysql_store_result(connect);

    unsigned int numrows = mysql_num_rows(res_set);

    cout << " Tables in " << DATABASE << " database " << endl;

    while (((row=mysql_fetch_row(res_set)) !=NULL))
    {
        cout << row[i] << endl;
    }

    mysql_close (connect);

    return 0;
}

以下包括:#include <mysql.h>生产 Unresolved inclusion: <mysql.h> . 知道如何解决这个问题吗?

最佳答案

你必须 configure Eclipse 的包含路径,让它找到文件 mysql.h

关于c++ - #include <mysql.h> 在 Eclipse for C++ 中不起作用 - 如何配置它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19445046/

相关文章:

php - mySQL 删除功能的问题

eclipse - 升级到 Eclipse 3.5 后的许多工具提示

java - 如何在 Eclipse 中使用 DonutProgress 库

c++ - vector<bool> 和数组之间的性能差距

c++ - 使用 QXmlItem 作为 QXmlQuery 焦点提取子节点值

c++ - 在 C++ 解释器中动态分配变量的最佳方法

c++ - 控制台输出中的意外字符

mysql - 如果另一个数据库2中存在同名的另一个表,Hibernate无法在数据库1中自动创建表

php - wamp中如何一次导入所有数据库

java - 带语言环境的 DecimalFormatSymbols