开发者

MySQL Connector C linking problem on VS2010

开发者 https://www.devze.com 2023-04-08 23:06 出处:网络
I am beginning on MySQL, and I encountered the error message while compiling the code: error LNK2001: unresolved external symbol _mysql_init@4

I am beginning on MySQL, and I encountered the error message while compiling the code:

error LNK2001: unresolved external symbol _mysql_init@4

I have searched the web, and did everything that seems to be the problem.

#include <my_global.h>
#include <mysql.h>
#define NULL 0
int main() {
  MYSQL * sql = mysql_init(NULL);
  return 0;
}

I ha开发者_开发问答ve checked that I have been using /MT option. Include, link directory added. I use release, and included "lib\opt".

libmysql.lib is in linker->input->additional dependency.

I have been using windows 7 x64 with VS2010 x86, and downloaded and installed MySQL Connector/C

Windows (x86, 64-bit), MSI Installer 6.0.2 (mysql-connector-c-6.0.2-winx64.msi)

What might be the problem, can anybody help?


After a careful investigation, I found that the problem raised from the x64 settings. x64 compilation option should be turned on when compiling an x64 project. In this case, platform should be switched from win32 to x64, and in project->properties->linker->advanced->target machine: x86 should be set to x64.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号