After creating a solution with cmake, I am being put face to face with 1400 errors in Visual Studio during build.
The main problem is, it seems no one compiles the connector, and just uses the precompiled library for their projects, more so on Windows.
Here are some of errors, it seems timespec is being redefined one more time, first of all in ,and then a second time in my_global.h, errors and definitons below.
So the question is, how the hell do I fix 1400 errors?
Or at least, some advice how to get rid of redefinition would be GREAT!
time.h
#ifndef _CRT_NO_TIME_T
struct timespec
{
time_t tv_sec; // Seconds - >= 0
long tv_nsec; // Nanoseconds - [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;
};
Error C2011 'timespec': 'struct' type redefinition (compiling source file C:\Users\DDubinin\Downloads\mysql-connector-c-6.1.6-src\mysys\my_mess.c) mysys c:\users\ddubinin\downloads\mysql-connector-c-6.1.6-src\include\my_global.h 660
Error C2039 'tv': is not a member of 'timespec' (compiling source file C:\Users\DDubinin\Downloads\mysql-connector-c-6.1.6-src\mysys\my_malloc.c) mysys c:\users\ddubinin\downloads\mysql-connector-c-6.1.6-src\include\my_global.h 681
Error C2227 left of '->tv' must point to class/struct/union/generic type (compiling source file C:\Users\DDubinin\Downloads\mysql-connector-c-6.1.6-src\libmysql\authentication_win\handshake.cc) auth_win_client c:\users\ddubinin\downloads\mysql-connector-c-6.1.6-src\include\my_global.h 681
Error C2227 left of '->max_timeout_msec' must point to class/struct/union/generic type (compiling source file C:\Users\DDubinin\Downloads\mysql-connector-c-6.1.6-src\libmysql\authentication_win\plugin_client.cc) auth_win_client c:\users\ddubinin\downloads\mysql-connector-c-6.1.6-src\include\my_global.h 682
I'll close this issue, managed to compile the source with an older ,VS2013 x64, version of Visual Studio, and CMake 4.3.1 ...
It seems, the new changes in Visual Studio 2015 are breaking the C connector source code, I hope that MySQL team will fix this in a future release.
i used mysql server code(i.e. mysql-5.7.13.zip) and compiled the MySQL Connector/C from it.
What motivated me to compile this code in vs 2015 is when I compiled mysqlcppconn 1.1.8, I got the error:
error LNK2038:mismatch detected for `_MSC_VER`:value '1800' does not match value '1900'
the 1800,1900 indicates the version of vs used.
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
I searched and discovered that it indicates my mysqlcppconn-static.lib downloaded from mysql was compiled using VS 2013, and it causes error in VS 2015.
I acctually followed this guide, and it worked fine for me.
http://nov11.github.io/jekyll/update/2017/04/24/compilemysqlcppconnector1.1.8.html
My os is windows 10 x86
To summarize, Follow the steps:
git clone mysqlcppconn source code and checkout the desired version
git clone https://github.com/mysql/mysql-connector-cpp.git
git checkout 1.1.8
download boost and mysql-server-code locally, and modify the CMakeLists.txt so the compiler can find the library
In that case, my boost version is boost_1_64_0, and mysql is mysql-5.6.26-win32. It can be downloaded here:https://cdn.mysql.com/archives/mysql-5.6/mysql-5.6.26-win32.zip
modify CMakeLists.txt, add lines:
SET(BOOST_ROOT "C:\\boost_1_64_0")
SET(MYSQL_DIR "C:\\mysql-5.6.26-win32")
SET(MYSQL_VERSION "5.6.26")
cmake:
mkdir build && cd build
cmake -G "Visual Studio 14 2015" -A win32 -DMYSQLCLIENT_STATIC_LINKING=yes ..
solve the snprintf link error:
comment out the define snprintf _snprintf line in my_config.h in mysql-server-include code
generate lib files:
cmake --build <your-build-folder-path> --config Release --target mysqlcppconn -j 4 --
cmake --build <your-build-folder-path> --config Release --target mysqlcppconn-static -j 4 --
Related
Thanks for #Praetorian 'help, problem Was solved.
That's what I do:
download the beta version of boost (present beta version: 1.64)
Do what's told here: How to use Boost in Visual Studio 2010
To install Boost, I have done what am I told(http://www.boost.org/doc/libs/1_63_0/more/getting_started/ and How to use Boost in Visual Studio 2010.)
But "argument error" still returned after running b2
What's the mistake do I make?
//What I do
$ b2 --toolset=msvc-14.0 --build-type=complete architecture=x86 address-model=64 stage
//Return
*** argument error
rule maybe-rewrite-setup ( toolset : setup-script : setup-options : version : rewrite-setup ? )
called with: ( msvc : : : default : )
missing argument setup-script
//Using
Visual Studio 2017 community
x86 Native Tools Command Prompt for VS 2017
I Include the file "libvlc.h" from the VLC main git repository (https://github.com/videolan/vlc.git) in my Visual Studio project, I get various error e.g.
The identifier "libvlc_int_t"" is not declared. Video [...]\vlc\src\libvlc.h 34
What am I doing wrong?
This is my (german) VS output:
http://pastebin.com/MkAeJzgv
I had the same in Visual Studio 2010 Update 1. However, it was easily fixed
replacing all the occurrences of "ssize_t" by "intptr_t".
Original comment by felipe.a...#gmail.com on 8 Feb 2013 at 1:22
It works.
define ssize_t to SSIZE_T in predefined headers (ex:"stdafx.h") in Visual studio .
When building a VS2013 solution (migrated from VS8) I get the following error :
Error 1 error C2220: warning treated as error - no 'object' file
generated C:\Program Files\Microsoft Visual Studio
12.0\VC\atlmfc\include\afx.h 38 Warning 2 warning C4996: 'MBCS_Support_Deprecated_In_MFC': MBCS support in MFC is deprecated
and may be removed in a future version of MFC. C:\Program
Files\Microsoft Visual Studio 12.0\VC\atlmfc\include\afx.h 38
This is caused bij the following code :
#ifdef _MBCS
// Warn about MBCS support being deprecated: see http://go.microsoft.com/fwlink/p/?LinkId=279048 for more information.
#pragma warning(push)
#pragma warning(1 : 4996)
inline __declspec(deprecated("MBCS support in MFC is deprecated and may be removed in a future version of MFC.")) void MBCS_Support_Deprecated_In_MFC() { }
class MBCS_Deprecated_MFC
{
public:
MBCS_Deprecated_MFC() { MBCS_Support_Deprecated_In_MFC(); }
};
#pragma warning(pop)
#endif
How can I find where _MBCS is defined in the solution. Find doesn't has any results.
The _MBCS symbol will be defined as a result of the settings in your project properties. Look at General->Character Set - this is what adds the required entries to the command line.
To continue using MBCS, you need to install the optional support from Microsoft here
As it notes in MSDN:
The code in your question actually gives a link to this blog post, which discusses the changes and includes a link to the download:
// Warn about MBCS support being deprecated: see http://go.microsoft.com/fwlink/p/?LinkId=279048 for more information.
So, you can either download the patch from the link above or migrate your application to UNICODE.
This constexpr code does not compiled in Visual Studio 2013 version 12.0.21005.1 REL
Is there a newer Visual Studio compiler that works with constexpr?
#include <iostream>
constexpr int factorial(int n)
{
return n <= 1 ? 1 : (n * factorial(n - 1));
}
int main(void)
{
const int fact_three = factorial(3);
std::cout << fact_three << std::endl;
return 0;
}
output from compilation:
1>------ Build started: Project: Project1, Configuration: Debug Win32 ------
1> Source.cpp
1>....\source.cpp(3): error C2144: syntax error : 'int' should be preceded by ';'
1>....\source.cpp(3): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Herb Sutter mentions constexpr on his blog but is unclear in what version it works / will work? http://herbsutter.com/2013/09/09/visual-studio-2013-rc-is-now-available/#comment-13521
Microsoft publishes a C++11 compatibility table, under which constexpr is clearly marked as not being available in Visual Studio 2013.
The November 2013 CTP has it, though.
Source: Google visual studio constexpr
constexpr is not supported in Visual Studio 2013 RTM, see the compatibility table. This is not only true for the RTM version, but also for the Visual Studio Updates.
If you want to stick to Visual Studio 2013, you could download the Visual C++ Compiler November 2013 CTP which comes with some new features, see MSDN blog. Unfortunately Microsoft has no merger with the latest Visual Studio Update features and the CTP features and clearly states that they don't plan to do so.
If we want it all, we need to wait for Visual Studio 2015, see the MSDN blog about VS 2015 Preview.
As is mentioned by the others, November 2013 Customer Technology Preview(CTP) will give you access to constexpr*
Note that just downloading the you'll need to change your "Platform Toolset" to "Visual C++ Compiler Nov 2013 CTP (CTP_Nov2013)" to use the new compiler. You can do that by opening your project's "Property Pages" And going to: "Configuration Properties" > "General" and then changing the "Platform Toolset".
*There is a bit of conflicting information on what portion of constexpr you actually have access to, but it's definitely not all of the standards definition of constexpr. Microsoft says here that the November 2013 CTP adds:
constexpr support (except for constructors)
Microsoft say here that it contains:
constexpr (except for member functions)
I can't even test if it has support for member functions, cause it definitely doesn't have support for any type of constexpr construction. For example this code gives this error with the November 2013 CTP:
error C2127: illegal initialization of 'constexpr' entity with a non-constant expression
One additional note: At time of writing the Visual Studio 2015 Preview still does not support constexpr construction. Keeping my fingers crossed on the final release.
You need to install VS2013 Update 5. (I was on Update 3 and it was not working)
The thing about "Nov 2013 CTP" was inapplicable, as of this writing.
You can do so by going here: https://my.visualstudio.com
and going to download, or :
https://my.visualstudio.com/Downloads?q=visual%20studio%202013
I need to use mpir-2.6.0 library with visual c++ 2010. My code is going to be in c++.
I extracted both folders (mpir-2.6.0 and vsyasm-1.2.0-win32). Then, I copied the content of the folder vsyasm-1.2.0-win32 (including vsyasm.exe after renaming it to yasm.exe and placing it in: C:\Program Files\Microsoft Visual Studio 11.0\VC\bin\. Then, I opened the project: mpir.sln which is placed in: \mpir-2.6.0\build.vc10. Then, I changed the Project configuration to: Release.
When I try to build the whole solution, I get a lot of errors such as:
error C1020: unexpected #endif c:\proj\mpir-2.6.0\mpir-2.6.0\mpir.h 4 1 lib_mpir_gc
error C1020: unexpected #endif c:\proj\mpir-2.6.0\mpir-2.6.0\mpir.h 4 1 lib_mpir_gc
error C1020: unexpected #endif c:\proj\mpir-2.6.0\mpir-2.6.0\mpir.h 4 1 lib_mpir_gc
But when I build every library separately, it is successful.
After the build, I went to: \mpir-2.6.0\build.vc10\Win32\Release
and find the files:
mpir.lib
mpirxx.lib
mpir.pdb
mpirxx.pdb
But I can not find the files:
mpir.h
mpirxx.h
Which I need to copy them the visual studio include file.
My main source for these configuration is: http://www.exploringbinary.com/how-to-install-and-run-gmp-on-windows-using-mpir/ (but this was for old versions for the library and the ysam). I do not understand the reasons for these errors. I was able to configure the library with old version. But I need to upgrade as there are improvements in the library and mine is very old one.
The output files are now located in mpir\lib\Win32\Release or mpir\dll\Win32\Release.
The recommended way to build MPIR specifcally for your CPU is to first run mpir_config.py which is located in the build.vc10 directory. mpir_config.py will prompt you with a list of CPU options. Then when you open mpir.sln, you should only compile code for the specific CPU. And then you compile the C++ wrapper (i.e. compile lib_mpir_p3 first, and then lib_mpir_cxx).
Edit: I just noticed another error from your original post. You need to rename the directory "mpir-2.6.0" to "mpir". The directory layout needs to be "<>\mpir\build.vc10"
I had the same problem with MPIR 2.6.0 and VS 2012. What I did to make MPIR work was to build lib_gc and lib_cxx, both with win32 and release mode. Because my c++ application is win32 console, this way it worked perfectly.
Becuase my windows is 64, I thought I had to build 64 versions, but turned out that I was wrong.