开发者

Unresolved symbol: sql::mysql::get_driver_instance(void)

开发者 https://www.devze.com 2023-03-29 15:31 出处:网络
I have a program that uses MySQL connector to talk to a MySQL database.The application runs fine using Visual Studio 2008.I\'m trying to get the application to build with Visual Studio 2010 and that\'

I have a program that uses MySQL connector to talk to a MySQL database. The application runs fine using Visual Studio 2008. I'm trying to get the application to build with Visual Studio 2010 and that's where the problems began.

The MySQL Connector 1.05 is not supported with VS 2010, and they don't have a binary version of 1.1.0 that works with VS 2010. The MySQL information says to download the source for Connector C++ 1.10 and build with VS 2010. After much work, I build it. The examples run.

However, when I build my application with the newly built Connector C++ 1.1.0, I get the following error message:

error LNK2019: unresolved external symbol "class sql::mysql::MySQL_Driver * __cdecl sql::mysql::get_driver_instance(void)" (?get_driver_instance@mysql@sql@@YAPAVMySQL_Driver@12@XZ) referenced in function "private: void __thiscall Database_NS::Manager::initialize_db_driver(void)const " (?initialize_db_driver@Manager@Database_NS@@ABEXXZ)

This is caused by the following source line:

sql::Driver * p_driver = sql::mysql::get_driver_instance();

The MySQL Connector C++ 1.1.0 examples use the above line and they get no errors. I've tried linking with mysqlconn-static.lib, mysqlconn.lib, mysqlclient.lib, libmysql.lib and still the error message persists.

An interesting point is that according to VS 2010, the above source line uses this declaration:

CPPCONN_PUBLIC_FUNC MySQL_Driver * get_driver_instance();

Note the different return values.

When I use Visual Studio 2010 and the connector project example, VS 2010 can't find the declaration or function declaration of get_driver_instance() used by connect.cpp. The statement in my program is the exact statement used by connect.cpp, since I copied it over without any changes.

Other people have resolved this issue by using another driver. However, I don't want to change my code that works with VS2008 unless I have to.

Another reply to this issue says to define "mysqlcppconn_EXPORTS", but this didn't work either, also reported in the comment to the reply.

Here are my questions:

1. Has anybody got MySQL Connector 1.1.0 to work with Visual Studio 2010?

If so, please reply with step by step example and indicate whether dll or static library.

2. How is the VS compiler selecting the get_driver_instance() function that returns MySQL_Driver * rather than the function that returns the Driver *?

I'm not even getting any warnings or errors about ambiguous functions (since overloading must differ by more than only return type).

I am using Visual 开发者_如何学JAVAStudio 2010 on Windows-7x64-bit, MySQL Connector C++ 1.1.0.

See also:

get_driver_instance() crashes with Qt

undefined reference to 'get_driver_instance'

MySQL C++ Connector: undefined reference to `get_driver_instance'

mysql-connector-c++ - ‘get_driver_instance’ is not a member of ‘sql::mysql’

How to fix unresolved external symbol due to MySql Connector C++?


Some function names have changed. My best solution is to differentiate between them by using preprocessor conditionals.


I too have the same problem, I keep getting:

*sampletest.obj : error LNK2001: unresolved external symbol __imp__get_driver_instance*

Although I tried a 32 bit connector and the issue was resolved (you may want to try that as, if you are lucky it may work for you), but I was using a 64bit mysql,windows 7 , so there was a bit of compatibility issue .. I am still searching for the solution for the above problem.

Followed the tutorials word by word , linked all libraries I think the C++ 1.10 connector might have some issue.

0

精彩评论

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