Can MySQL's Connector/C++ work with Visual Studio 2017? - c++

I kept hearing Connector/C++ should run on the compiler that it was compiled on, and one document says that's Visual C++ 2013. I'm using Visual C++ 2017 and I'm not downgrading. The document may have been old, so I'm curious if anyone has had any success and what you did to make it work.

Yes it will definately work. You just have to add include path and library path of MySQL to your VC++ directories ( Project -> Properties -> VC++ directories).
Now that you have included path you can directly use mysql.h header to call mysql c functions.

No, for C++ you have to find a version that got compiled with the same settings as your project. You can switch to using the C version of the connector which does not suffer from C++'s lack of ABI. You can find the C tutorial here.
If you would like to try your luck with C++, then make sure the build settings of the library you use match your project:
version of Visual Studio
version of stl
exception handling
vtable layout
stack and stack frame padding
Bitness (32 vs 64)
Iterator debug level
runtime linkage (MT vs MD)
build configuration (Debug vs Release)
characterset (multibyte vs unicode)
Fortunately the linker will check the compiler version _MSC_VER and will not allow you to link to the older library.

Related

MSVCP140.dll missing

I just developed my first program in C++ and I wanted to share it with one of my friends.
But when he tries to open the exe it gets an error which says "MSVCP140.dll is missing". Why is this issue happening and how can we fix it?
Either make your friends download the runtime DLL (#Kay's answer), or compile the app with static linking.
In visual studio, go to Project tab -> properties - > configuration properties -> C/C++ -> Code Generation on runtime library choose /MTd for debug mode and /MT for release mode.
This will cause the compiler to embed the runtime into the app. The executable will be significantly bigger, but it will run without any need of runtime dlls.
Your friend's PC is missing the runtime support DLLs for your program:
Visual C++ Redistributable for Visual Studio 2015
That usually means that your friend does not have the Microsoft redistributable for Visual C++. I am of course assuming you are using VC++ and not MingW or another compiler. Since your friend does not have VS installed as well there is no guarantee he has the redist installed.
VC++ Distro
That's probably the C++ runtime library. Since it's a DLL it is not included in your program executable. Your friend can download those libraries from Microsoft.

Visual Studio 2013 msvcr120 to msvcr100

Is it possible to change the restrib file to msvcr100 so other computers can run the program without having problems with the .dll file? If so how do i get that?
I do compile the program and other people can't use it because of the missing msvcr120.dll file. So it would be great if i could change that somehow.
Is it possible to install the Plattformtoolset without a older Visualstudio version?
You have a few choices:
Install VS2010 on the machine, and set the Platform Toolset option to v100.
Install the Windows SDK v7.0A from here, which SHOULD / CAN add a new option to your Platform Toolset menu in VS2013. Getting this to work can be quite fiddly though. (It's rarely worked for me right out of the box). Note if you use MFC in your application, this option isn't any good for you - MFC libraries are not included with this SDK.
Get your users to install the Microsoft VS 2013 C++ Redistributable Package from here, and carry on regardless.
Statically link to the VS2013 runtimes, instead of using dynamic linking to the runtime DLLs. You can set this in the IDE through project settings under C/C++ > Code Generation > RunTime Library > Multi-threaded (/MT) or (/MTd). All the needed code will be compiled into your app, which will make the files bigger, but will avoid the issues you mention.
In Project > Properties > General, there is a setting called Platform toolset. You can use that to change the version of the build toolchain used.
One thing to consider in regards to changing the platform toolset: it changes the compiler, so C++ features newer than Visual Studio 2010 will not compile. It also requires the other version to be installed.
The best way to handle this would be to give them the Visual C++ Redistributable for Visual Studio 2013.
You could either have them do it themselves, or make an installer.

How to do static linking in Eclipse CDT?

I am trying to statically link to a third party C library in C++.
I managed to do this in Visual Studio just by specifying the .lib file in the linker input options. However, when I do the equivalent in CDT (Project Properties -> Settings -> MinGW C++ Linker -> Libraries) I get endless amounts of "undefined reference to..." errors when I try to build.
Is there anything else that I need to do to achieve static linking in CDT?
Thanks,
Alan
If that third party library is build for Visual C environment and with the Microsoft Visual Studio compiler, you might be unable to link it with the MinGW compilers.
However, you can configure Eclipse CDT on Windows to compile your code with the Visual Studio command line compiler CL.EXE and then things should work as you expected.
It heavily depends on which version of Eclipse CDT you are using, because the Microsoft compiler settings plug-in is only part of the newer versions (I think its from Helios on).

C++ coding in eclipse...help with code assist

How can i get C++ coding in eclipse to act like coding in java?
In java, i can nicely add external jar files and the code assist can nicely suggest methods or suggest adding unimplemented methods for interfaces.
But in C++ mode, it doesn't seem to work when i include external header files. What else should i try?
Eclipse CDT itself does not come with any compilers/libraries therefore you need to select and install a toolchain. There are a few options for this
Visual Studio (cl)
MinGW (g++)
Cygwin (g++)
Note, you can get VS Express for free and if you are a student can even get the professional version from Dreamspark
Once you have installed any of these you can select them as the toolchain for your C/C++ projects, this will enable you to build your projects nicely from within eclipse.
Also, you may need to point eclipse to the library files used by your compiler, for instance I use the VS2010 toolchain under Eclipse CDT so I must add
"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include"
to the include directories in build settings.
Edit: Sorry if it wasn't clear, once you've done this code completion should work for your C/C++ projects.

How can I build VS 2010's C Runtime Library?

I need to modify the C runtime which ships with VS2010 because the 2010 CRT relies on functions released in Windows XP SP2, and I need to be able to deploy to Windows 2000.
Specifically, I need to remove any and all calls to EncodePointer and DecodePointer.
The source for the C runtime is included in C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\crt\src, so it seems like it should be possible to build the runtime after slightly modifying the source.
Oh, I don't need to be able to build the dynamic versions of the runtime -- static versions only. (I cannot rely on the user installing the CRT on their system either).
With VS2008 and earlier, there was a tutorial in MSDN describing how to build the CRT, but I can't seem to find it for 2010.
Is such a thing possible?
Here's an MSDN link. It looks like you have to do it yourself in VS2010.
You can use the following compiler and linker options to rebuild the MFC, CRT, and ATL libraries. Starting in Visual C++ 2010, scripts for rebuilding these libraries are no longer shipped.
If it is a option, I would consider using the VC++ 2008 toolset within VS2010 instead of building a custom CRT. The procedure is explained here.
"Oh, I don't need to be able to build the dynamic versions of the runtime -- static versions only."
Since you only need static linking, you can try this trick to provide implementations of EncodePointer and DecodePointer.