【发布时间】:2016-12-07 22:42:10
【问题描述】:
我是 Visual C++ 的新手。我想使用 MySQL/C++。 所以,我
- 在我的机器上安装了 MySQL 在我的机器上安装了 VS 2010 Professional 机器
- 从网上发现My SQL的驱动在
C:\Program Files\MySQL\Connector.C++ 1.1\include
C:\Program Files\MySQL\Connector.C++ 1.1\lib
- 我做了一个示例程序,是从this复制过来的。
- 构建项目
- 遇到与 boost 相关的错误
- 从Download boost_1_61_0.7z (74.8 MB) 下载 Boost
- 解压存档
- 使用 Project Properties > C/C++ > General > Additional Include Directories 添加了包含路径
- 使用项目属性>链接器>常规>附加库目录添加了链接器附加库
- 构建项目
- 现在它失败并出现以下错误
1>DemoDB.obj:错误 LNK2019:未解析的外部符号 "__declspec(dllimport) 公共:类 std::basic_string,类 std::allocator > const & __thiscall sql::SQLException::getSQLState(void)const " (__imp_?getSQLState@SQLException@sql@@QBEABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) 在函数 __catch$_wmain$0 中引用
1>DemoDB.obj:错误 LNK2019: 未解析的外部符号“__declspec(dllimport) public: int __thiscall sql::SQLException::getErrorCode(void)const " (__imp_?getErrorCode@SQLException@sql@@QBEHXZ) 在函数中引用 __catch$_wmain$0 1>DemoDB.obj:错误 LNK2019:无法解析的外部符号“__declspec(dllimport) public: __thiscall sql::SQLString::~SQLString(void)" (__imp_??1SQLString@sql@@QAE@XZ) 在函数 _wmain 中引用
1>DemoDB.obj:错误 LNK2019:未解决 外部符号“__declspec(dllimport) public: __thiscall sql::SQLString::SQLString(char const * const)" (__imp_??0SQLString@sql@@QAE@QBD@Z) 在函数_wmain中引用
1>DemoDB.obj:错误 LNK2019:未解析的外部符号 __imp__get_driver_instance 在函数 _wmain 中引用
1>DemoDB.obj:错误 LNK2019:无法解析的外部符号“__declspec(dllimport) 公共:类 std::basic_string,类 std::allocator > const & __thiscall sql::SQLString::asStdString(void)const " (__imp_?asStdString@SQLString@sql@@QBEABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) 在函数“class std::basic_ostream > & __cdecl std::operator &,类 sql::SQLString 常量 &)" (??6std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@ABVSQLString@sql@@@Z)
请帮忙。我完全卡住了
编辑:
此行导致以下错误
cout << ", SQLState: " << e.getSQLState() << " )" << endl;
1>DemoDB.obj:错误 LNK2019:未解析的外部符号 "__declspec(dllimport) 公共:类 std::basic_string,类 std::allocator > const & __thiscall sql::SQLException::getSQLState(void)const " (__imp_?getSQLState@SQLException@sql@@QBEABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) 在函数 __catch$_wmain$0
中引用
到目前为止,我已经在下面提到过,但没有帮助
【问题讨论】:
-
可能您安装的 MySQL 驱动程序来自不同版本的 Visual Studio。
-
@drescherjm 我从这个链接下载了 MySQL (v5.7.14)。我如何知道 MySQL for Visual Studio 的兼容性?链接 --> cdn.mysql.com//Downloads/MySQLInstaller/…
-
您使用的 MySQL 库是否使用编译指示自动链接?
-
@drescherjm 我相信它有,因为即使我没有使用#pragma,我的库也被链接了。我解决了这个定义预处理器宏“CPPCONN_PUBLIC_FUNC="
-
如果这个问题得到解决,您应该发布您的解决方案作为答案。
标签: c++ mysql visual-studio-2010 boost