編輯:C++連接到MySQL
我的問題是在這篇文章的底部的錯誤。
我的繼承人附加包含目錄
C:\Program Files\boost
C:\Program Files\MySQL\MySQL Connector C++ 1.1.3\include
C:\Program Files\MySQL\MySQL Server 5.6\include
附加庫目錄
C:\Program Files\MySQL\MySQL Server 5.6\lib
C:\Program Files\MySQL\Connector C++ 1.1.2\lib\opt
附加依賴
libmysql.lib
mysqlcppconn-static.lib
繼承人我的代碼
#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;
#include <stdlib.h>
#include <Windows.h>
#include <mysql.h>
#include "mysql_connection.h"
#include <cppconn/driver.h>
#define host "localhost"
#define username "root"
#define password "root"
#define database "tests"
int main()
{
MYSQL* conn;
conn = mysql_init(NULL);
if(conn)
{
mysql_real_connect(conn, host, username, password, database, 0, NULL, 0);
}
MYSQL_RES* res_set;
MYSQL_ROW row;
unsigned int i;
mysql_query(conn, "SELECT * FROM tbl_clients WHERE id = 1");
res_set = mysql_store_result(conn);
unsigned int numrows = mysql_num_rows(res_set);
if(numrows)
{
row = mysql_fetch_row(res_set);
if(row != NULL)
{
cout << "Client ID : " << row[0] << endl;
cout << "Client Name: " << row[1] << endl;
}
}
if(res_set)
{
mysql_free_result(res_set);
}
if(conn)
{
mysql_close(conn);
}
return 0;
}
這些都是錯誤的,我得到
1>------ Build started: Project: okay, Configuration: Debug Win32 ------
1>welp.obj : error LNK2019: unresolved external symbol [email protected] referenced in function _main
1>welp.obj : error LNK2019: unresolved external symbol [email protected] referenced in function _main
1>welp.obj : error LNK2019: unresolved external symbol [email protected] referenced in function _main
1>welp.obj : error LNK2019: unresolved external symbol [email protected] referenced in function _main
1>welp.obj : error LNK2019: unresolved external symbol [email protected] referenced in function _main
1>welp.obj : error LNK2019: unresolved external symbol [email protected] referenced in function _main
1>welp.obj : error LNK2019: unresolved external symbol [email protected] referenced in function _main
1>welp.obj : error LNK2019: unresolved external symbol [email protected] referenced in function _main
1>C:\Users\Damian\documents\visual studio 2012\Projects\okay\Debug\okay.exe : fatal error LNK1120: 8 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
請幫幫忙,這個項目是因爲在我的班級約48小時,我已經花了這麼多時間試圖弄清楚這一點。
謝謝
哇感謝您的快速響應,只是編輯了我的上述帖子,並看到您的回覆。我會繼續努力吧 – 2013-05-09 15:52:55
是的,他是對的。我錯過了指定** mysql.lib ** – Sanoob 2013-05-09 16:13:14
那麼,至今仍然無濟於事。在任何文件夾中都沒有mysql.lib。我知道,當你說你只是在猜測,但如果我不得不猜測它是哪一個,我猜它必須是libmysql.lib。我已經包括了這一點,但仍然沒有。我一直在閱讀關於所有這些事情,我仍然卡住。 – 2013-05-09 18:52:41