mysql c库 错误码,MySQL Connector / C ++库链接错误问题

PROBLEM:

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?

CODE:

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;

}

ERROR OUTPUT:

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 ==========

UPDATE:

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!

解决方案

You must first change your code:

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

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

Here add the path of your lib.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值