0
我的源代碼,結果是:Visual C++ MySQL連接器/ C錯誤?
// MySQL.cpp : Defines the entry point for the console application.
//
#include <iostream>
#include <winsock.h>
#include <string>
#include <sstream>
#include <stdio.h>
#include <mysql.h>
#define TABLE_OF_INTEREST "some_table"
#define SERVER_NAME "mysql_server"
#define DB_USER "user"
#define DB_USERPASS "pa55w0rd"
#define DB_NAME "db_name"
#define NEWLINE "\n"
using namespace std;
int main()
{
MYSQL *hnd = NULL; // mysql connection handle
const char *sinf = NULL; // mysql server information
if(!mysql_real_connect(hnd, SERVER_NAME, DB_USER, DB_USERPASS, DB_NAME, 0, NULL, 0)
cout << "Something happened.";
return 0;
}
錯誤:
1>------ Build started: Project: MySQL, Configuration: Release Win32 ------
1> MySQL.cpp
1>MySQL.obj : error LNK2001: unresolved external symbol [email protected]
1>c:\users\josiah\documents\visual studio 2010\Projects\MySQL\Release\MySQL.exe : fatal error LNK1120: 1 unresolved external
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
我不認爲與源有問題,我只需要對如何找出其中的問題是幫助。
.lib將被調用什麼? – Yoshiyahu 2011-05-24 01:02:06
libmysql.lib,它的可能位置是C:\ Program Files文件(x86)\ MySQL \ MySQL連接器C x.x.x \ lib – Avery3R 2011-05-24 01:28:14
啊,不,我已經添加了libmysql.lib整個時間。 – Yoshiyahu 2011-05-24 01:59:16