在用cmake创建了一个解决方案之后,我将在构建过程中面对Visual中的1400个错误。主要的问题是,似乎没有人编译连接器,而只是在他们的项目中使用预编译库,更多的是在Windows上。下面是一些错误,现在似乎会重新定义一次,首先是在my_global.h中,然后是在下面的错误和定义中。
所以问题是,我到底该怎么纠正1400个错误?
或者,至少,一些建议,如何摆脱重新定义将是伟大的!
time.h #ifndef _CRT_NO_TIME_T struct time.h{ time_t tv_sec;//秒- >= 0 long tv_nsec;//纳秒- 0,999999999 };#endif my_global.h
struct timespec {
union ft64 tv;
/* The max timeout value in millisecond for native_cond_timedwait */
long max_timeout_msec;
};错误c:\users\ddubinin\downloads\mysql-connector-c-6.1.6-src\include\my_global.h C2011:'struct‘类型重新定义(编译源文件C2011 mysys c:\users\ddubinin\downloads\mysql-connector-c-6.1.6-src\include\my_global.h 660 )
Error C2039 'tv':不是“timespec”的成员(编译源文件c:\users\ddubinin\downloads\mysql-connector-c-6.1.6-src\include\my_global.h 681 )
class->tv的左转错误C2227必须指向类/struct/union/generic(编译源文件c:\users\ddubinin\downloads\mysql-connector-c-6.1.6-src\include\my_global.h auth_win_client 681 )
'->max_timeout_msec‘>左边的错误C2227必须指向类/struct/union/泛型类型(编译源文件c:\users\ddubinin\downloads\mysql-connector-c-6.1.6-src\include\my_global.h auth_win_client 682 )
发布于 2015-12-05 19:42:56
我将结束这个问题,设法用旧的Visual版本VS2013 x64和CMake 4.3.1编译源代码。
看来,Visual 2015中的新变化正在破坏C连接器源代码,我希望MySQL团队在以后的版本中能够解决这个问题。
发布于 2016-06-28 01:56:33
我使用mysql服务器代码(即MySQL5.7.13.zip)并从它编译了MySQL连接器/C。
发布于 2022-11-07 08:52:30
促使我在vs 2015中编译这段代码的原因是,当我编译mysqlcppconn 1.1.8时,我得到了错误:
error LNK2038:mismatch detected for `_MSC_VER`:value '1800' does not match value '1900'1800,1900表示所用vs的版本。
MSVC++14.0 _MSC_VER == 1900 (Visual Studio 2015)
MSVC++12.0 _MSC_VER == 1800 (Visual Studio 2013)
MSVC++11.0 _MSC_VER == 1700 (Visual Studio 2012)
MSVC++10.0 _MSC_VER == 1600 (Visual Studio 2010)
MSVC++9.0 _MSC_VER == 1500 (Visual Studio 2008)
MSVC++8.0 _MSC_VER == 1400 (Visual Studio 2005)
MSVC++7.1 _MSC_VER == 1310 (Visual Studio 2003)
MSVC++7.0 _MSC_VER == 1300
MSVC++6.0 _MSC_VER == 1200
MSVC++5.0 _MSC_VER == 1100我搜索并发现,它表明我从mysql下载的mysqlcppconn-static.lib是使用VS 2013编译的,并在VS 2015中导致错误。
我确实遵循了这个指南,它对我来说很好。
http://nov11.github.io/jekyll/update/2017/04/24/compilemysqlcppconnector1.1.8.html
我的操作系统是windows 10 x86
概括地说,遵循以下步骤:
CMakeLists.txt,以便编译器可以找到库。
在这种情况下,我的boost版本是boost_1_64_0,mysql是mysql-5.6.26-win32。它可以在这里下载:https://cdn.mysql.com/archives/mysql-5.6/mysql-5.6.26-win32.zip
修改CMakeLists.txt,添加行:
SET(BOOST_ROOT "C:\boost_1_64_0") SET(MYSQL_DIR“C:\mysql-5.6.26-Win 32”) SET(MYSQL_VERSION "5.6.26")snprintf link error:
注释掉mysql- my_config.h中的my_config.h行--包括代码https://stackoverflow.com/questions/34091321
复制相似问题