如何构建 MySQL 连接器 c++在 Windows x64 机器上使用 VS 2010?

发布于 2025-01-05 03:33:17 字数 1737 浏览 4 评论 0原文

这似乎是一个获得我想要的东西的 PITA:在 Windows x64 机器上工作的 MySQL Connector/C++。

我已经尝试过的:

  • 我首先尝试了 MySQL 下载站点上的二进制包,在那里我必须从其他地方添加缺少的包含文件(sqlstring.h)(请参阅 这里
  • 然后我的测试代码编译了,但没有运行,因为缺少 libmysql.dll (再次不包含在二进制文件中包裹)
  • 我发现 Connector/C 包中包含这个 dll,所以我从那里获取了它。现在,我的连接器在调试模式下工作正常。但当我处于发布模式时,会发生非常奇怪的事情。有时,尝试连接时应用程序会退出且没有任何警告。有时它告诉我,我的非常简单的语句(SELECT * FROM sometable)中有一个 SQL 语法错误,该语句在调试模式下工作正常。
  • 然后我发现这里最好从源代码构建连接器,所以我试过了。 C++ 连接器需要 C 连接器,并且在遇到一些麻烦后(我不得不修补 CMakeFile.txt 因为这个 bug)我成功构建了 C 连接器。
  • 我还设法使用 CMake 为 C++ 连接器生成 VS 解决方案,但现在我陷入困境。由于缺少一些包含文件,存在太多构建错误...我不知道这是我的 CMake 配置问题,还是它无法与 VS2010 配合使用,或者只是有问题。

在 Win x64 机器上使用 MySQL C++ 连接器(用 VS2010 构建)是不是很不寻常? 一定有更简单的方法让它工作,对吗?

我将不胜感激任何提示。

更新

我认为我应该更准确地描述我的构建错误:

首先,我

<path_to_mysql_connector_cpp_build>
<path_to_mysql_connector_cpp_build>\cppconn
<path_to_mysql_connector_cpp_build>\driver\nativeapi

按顺序添加到 mysqlcppconnmysqlcppconn-static 项目包含目录查找 config.hcppconn/config.hdriver/nativeapi/binding_config.h 包含文件。

但现在,一些 my_global.h 文件丢失了,我找不到它。它似乎在 MySQL 服务器的包含文件中,但我认为连接器不需要该服务器。

我刚刚在这里找到了一条评论 ,指出 C++ 连接器与 VS2010 尚不兼容(那是在 2011 年 10 月)。

那么,如果 MySQL 下载站点上的预构建二进制文件无法正常工作,我该怎么办?

It seems to be a PITA to get what I want: a working MySQL Connector/C++ on a Windows x64 machine.

What I already tried:

  • I first tried the binary packages on the MySQL download site, where I had to add a missing include-file (sqlstring.h) from some other place (see here)
  • Then my test code compiled, but didn't run because a libmysql.dll was missing (again not included in the binary package)
  • I found out that the Connector/C package contained this dll, so I took it from there. Now, my Connector is working fine... in Debug mode. But really strange things happen when I'm in Release mode. Sometimes the application quits without any warning when trying to connect. Sometimes it tells me I have a SQL syntax error in my very simple statement (SELECT * FROM sometable), which works fine in Debug mode.
  • I then found out here that it is preferrable to build the connector from source, so I tried that. The C++ connector needs the C-connector and after some trouble (I had to patch a CMakeFile.txt because of this bug) I managed to build the C connector.
  • I also managed to generate a VS solution with CMake for the C++ connector, but now I'm stuck. There's too many build errors because of some missing include files... I don't know if it's my CMake configuration or if it's not working with VS2010 or if it's just buggy.

Is it so unusual to use the MySQL C++ connector (built with VS2010) on a Win x64 machine?
There must be an easier way to get it working, right?

I'd be grateful for any hints.

UPDATE

I think I should be more precise on my build errors:

First, I added

<path_to_mysql_connector_cpp_build>
<path_to_mysql_connector_cpp_build>\cppconn
<path_to_mysql_connector_cpp_build>\driver\nativeapi

to the mysqlcppconn and mysqlcppconn-static project include directories in order to find the config.h , the cppconn/config.h and the driver/nativeapi/binding_config.h include files.

But now, some my_global.h file is missing and I can't find it. It seems to be within the include files for the MySQL server, but I thought that the server wasn't needed for the connector.

And I just found a comment here, stating that the C++ connector isn't compatible with VS2010 yet (that was in october 2011).

So what can I do if the prebuilt binaries from the MySQL download site aren't working properly?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

昔梦 2025-01-12 03:33:17

我最终使用了 MySQL Connector/C 并编写了自己的 C++ 包装器。
目前它非常简单并且缺少很多功能,但是每次需要使用它时我都会添加功能。

无论如何,我不太喜欢 MySQL Connector/C++,因为它不是以 RAII 风格编程的。

I ended up using the MySQL Connector/C and writing my own C++ wrapper.
For now it's very simple and misses a lot of functionality, but I will add functionality every time I have to use it.

I didn't like the MySQL Connector/C++ too much anyway, as it wasn't programmed in RAII-style.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文