MySQL C ++连接器未解析的外部符号_get_driver_instance [英] MySQL C++ Connector unresolved external symbol _get_driver_instance

查看:1816
本文介绍了MySQL C ++连接器未解析的外部符号_get_driver_instance的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用连接器C ++ 1.1.3在Win 8与VS 2010 Express。

I'm using Connector C++ 1.1.3 on Win 8 with VS 2010 Express.

对于我的调试生成链接 - >通用 - >附加库目录有:C:\Program Files\MySQL\Connector C ++ 1.1.3 \lib \debug

For my debug build in Linker->General->Additional Library Directories I have: C:\Program Files\MySQL\Connector C++ 1.1.3\lib\debug

在链接器 - >输入中我有:mysqlcppconn.lib

In Linker->Input I have: mysqlcppconn.lib

我收到链接器错误:Server.obj:error LNK2019:未解析的外部符号_get_driver_instance在函数public:bool __thiscall Server :: Init(void) @ Server @@ QAE_NXZ)

I get linker error: Server.obj : error LNK2019: unresolved external symbol _get_driver_instance referenced in function "public: bool __thiscall Server::Init(void)" (?Init@Server@@QAE_NXZ)

我在其他include目录中获得提升:C:\Users\MyName\Downloads\boost_1_55_0\boost_1_55_0

I have boost in additional include directorys : C:\Users\MyName\Downloads\boost_1_55_0\boost_1_55_0

我假设get_driver_instance()在mysqlcppconn.lib中定义。

I would assume get_driver_instance() is defined in the mysqlcppconn.lib.

 #include <cppconn/driver.h>
 #include <cppconn/exception.h>
 #include <cppconn/resultset.h>
 #include <cppconn/statement.h>

 class Server
 {
 private:
    sql::Driver* sqlDriver;
sql::Connection* sqlConn;
 public:
    bool Init();
 };

 bool Server::Init()
 {
    sqlDriver = get_driver_instance();
    return true;
 }

我知道这里有很多话题,解决了。

I know there are a bunch of topics on this but nothing I've tried has solved it. I haven't written all the things I've tried down as there are a bunch of things.

推荐答案

我也有同样的想法问题,最后通过切换到释放而不是调试来解决它。

I had the same problem and ended up solving it by switching to "Release" instead of "Debug".

其他相关问题由这个小小的改变解决。 (请参阅 mysql C ++中的连接崩溃

Other related problems are solved by this small change. (See Connection Crash in mysql C++ )

我知道你使用Qt库解决了这个问题,但我想这可以帮助其他人被困在同一个地方。

I understand that you solved this using Qt library, but I guess this can help for other people that got stuck in the same place.

编辑:
我一直在对mysql网站进行一些研究( http://dev.mysql.com/downloads/connector/cpp/ ),并清楚地说明:
可能出现的一个问题是,当用于构建应用程序的工具与用于构建MySQL Connector / C ++的二进制版本的工具不兼容。理想情况下,您需要使用用于构建MySQL连接器/ C ++二进制文件的相同工具构建您的应用程序。

I've been doing some research on the mysql site (http://dev.mysql.com/downloads/connector/cpp/) and it clearly states that: One problem that can occur is when the tools you use to build your application are not compatible with the tools used to build the binary versions of MySQL Connector/C++. Ideally, you need to build your application with the same tools that were used to build the MySQL Connector/C++ binaries.

我发现到目前为止的解决方案是下载库的源格式(不是二进制)和编译它与我需要的设置。

The solution I've found so far is to download the library in source format (not binary) and compile it with the settings I need.

这篇关于MySQL C ++连接器未解析的外部符号_get_driver_instance的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆