如何解决Visual C ++ MySQL Connector / 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,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 _mysql_real_connect@32
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 ==========
我认为源不存在问题,我仅需要有关如何确定问题出在哪里的帮助。
解决方法
您缺少对库的引用。 C连接器应该带有一个.lib,将其添加到链接器的其他输入中
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。