【发布时间】:2015-12-03 07:48:25
【问题描述】:
我正在尝试在 Windows 8.1 上的 CodeBlocks 13.12 IDE 中使用 C 连接到 MySQL 服务器。以下是我的构建选项。
我的代码如下。
#ifdef WIN32
#include <windows.h>
#include <winsock.h>
#pragma warning (disable: 4514 4786)
#pragma warning( push, 3 )
#endif
#include <stdio.h>
#include <mysql.h>
#ifndef WIN32
#include <unistd.h>
#endif
int main(int argc, char **argv)
{
MYSQL mysql;
if(mysql_init(&mysql)==NULL){
printf("\nFailed to initate MySQL connection");
exit(1);
}
/*now you can call any MySQL API function you like*/
if(!mysql_real_connect(&mysql,"localhost","user","password","molecules",0,NULL,0)){
printf( "Failed to connect to MySQL: Error: %s\n",
mysql_error(&mysql));
exit(1);
}
printf("Logged on to database sucessfully");
mysql_close(&mysql);
}
我收到以下错误。
谁能帮帮我?
【问题讨论】:
标签: mysql c windows codeblocks linker-errors