MySQL Connector/C ++库链接错误问题 [英] MySQL Connector/C++ Library Linking ERROR Problem

查看:147
本文介绍了MySQL Connector/C ++库链接错误问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题:

好的,我一直在尝试遵循MySQL Forge Wiki和其他一些网站上的示例代码,这些示例代码提供了有关如何获得简单数据库连接的教程,但是由于某些原因,我的项目始终会因链接错误而失败而且我自己也不知道为什么或如何修复它(我仍在学习).请帮我!我已经在项目属性中包括了头文件所需的路径目录,并提供了在MySQL Connector/C ++中使用的lib文件的路径目录.如果有人可以给我有关如何修复它的有用提示/评论,则我正在使用的代码如下.我认为这与连接到lib文件有关(由于链接错误),但是我不知道解决该问题的解决方案.其他人有这样的麻烦吗?

Ok, I've been TRYING to follow the sample code on the MySQL Forge Wiki and some other websites that offer a tutorial on how to get a simple database connection, but for some reason, my project always fails at a linking error and I can't figure out why or how to fix it myself (I'm still learning). PLEASE HELP ME! I've included the path directory needed for the header files in the project properties AND provided the path directory to the lib files that are used in the MySQL Connector/C++. The code I'm using is below if someone could give me a helpful hint/ comment on how to fix it. I think it has something to do with connecting to the lib files (because of the linking error) but I don't know of a solution to fix it. Has anyone else had trouble like this?

http://forge.mysql.com/wiki/Connector_C++ http://dev.mysql.com/tech-资源/文章/mysql-connector-cpp.html#createdb

代码:

int main() {
    // do something
    sql::mysql::MySQL_Driver *driver;
    sql::Connection *con;
    sql::Statement *stmt;
    sql::ResultSet *res;
    sql::PreparedStatement *pstmt;

    cout << "Starting Driver Instance" << endl;
    driver = sql::mysql::MySQL_Driver::get_mysql_driver_instance();

    return 0;
}

错误输出:

1>------ Build started: Project: test, Configuration: Debug Win32 ------
1>Compiling...
1>main.cpp
1>c:\users\josh bradley\documents\visual studio 2008\projects\test\test\main.cpp(28) : error C2039: 'get_mysql_driver_instance' : is not a member of 'sql::mysql::MySQL_Driver'
1>        c:\program files\mysql\mysql connector c++ 1.0.5\include\mysql_driver.h(25) : see declaration of 'sql::mysql::MySQL_Driver'
1>c:\users\josh bradley\documents\visual studio 2008\projects\test\test\main.cpp(28) : error C3861: 'get_mysql_driver_instance': identifier not found
1>Build log was saved at "file://c:\Users\Josh Bradley\Documents\Visual Studio 2008\Projects\test\test\Debug\BuildLog.htm"
1>test - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

更新:

我只是想让所有人都知道,我终于找到了解决问题的方法.对于有类似问题的任何人,请访问 http://blog.ulf-wendel. de/?p = 215#hello 并通读有关如何动态连接到mysqlcppconn.lib的说明.我的问题是设置实际环境,以便它可以正确连接到库,并且本教程对您有很大帮助!

I just wanted to let everybody know that I finally found out how to fix my problem. For anyone having a similar problem, go to http://blog.ulf-wendel.de/?p=215#hello and read through the instructions on how to connect to the mysqlcppconn.lib dynamically. My problem was setting up the actual environment so it would connect to the library correctly and this tutorial helped tremendously!

推荐答案

您必须先更改代码:

driver = sql::mysql::get_mysql_driver_instance();

接下来,您必须将代码链接到mysqlclient.lib 在项目上添加lib mysqlclient.lib 的正确路径:

And next, you have to link your code with mysqlclient.lib Add the right path of your lib mysqlclient.lib on your project:

Properties->Linker->General-> Additionnal Libraries

在这里添加您的lib的路径.

Here add the path of your lib.

这篇关于MySQL Connector/C ++库链接错误问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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