visual studio 2012 mingw and format error - c++

I'm taking a c++ class and the instructor has stated that we can use any IDE that we like however, he will be compiling our .cpp and .h files using mingw. I'm using Visual Studio 2012. How should be creating projects using VS2012 to ensure that they will compile with mingw? Can I start the project as win32 or should I use a general empty project? Compilers and dll's are an enigma to me.
I also have code::blocks installed from a previous class and then just to really screw up my default settings and directories I downloaded and installed Visual Studio 2015 in an attempt to upgrade. I have since uninstalled VS2015 and all of the other software that installed at the same time. Now, anytime I start a new project in VS2012 I get the error:
An attempt was made to load a program with an incorrect format
(Exception from HRESULT 0X8007000B)
I suspect that when I installed VS2015 something changed where my x86 VS2012 is looking trying to use x64 or something other than Visual Studio 11.
I'd love to fix that glitch if you can help.
Thanks

Related

Is it possible to have VS2010 and VS2012 projects concurrently on the same source code

I have a VS2010 library project that I would like to use in a new app in VS2012. Of course when I open VS2012 it wants to update the library project. Is there any way of having two projects - one for VS2010 and one for VS2012?
We have a large product portfolio and not all apps will move to VS2012 at the same time.
Generally, as long as you're running VS2010 SP1, everything will work appropriately opening the project with both versions of VS.
For C++ compatibility specifically:
You can use Visual Studio 2012 to open a C++ project that was created in Visual Studio 2010 SP1. If you want to use the Visual Studio 2012 build environment to build a project that was created in Visual Studio 2010 SP1, you must have both versions of Visual Studio installed on the same computer.
The full list of compatibility information can be found on msdn

How to correctly install platform toolsets

I know there are tons of other threads about it, but I couldn't find any which could help me.
So I've got VS2013 Ultimate installed. I've got an old project which works with only VS2008SP1. On other compilers it has compatibility issues which I don't want to bother with. So I would like to try to compile it from 2013 with 2008 tools, so I hope I can compile it without uninstalling my current VS2013.
So, if I install VS2008, will this overwrite my current 2013 or just getting added as a toolset?
If I use 2008 toolset, will this work the same way as I had a VS2008?
Do I have to do something else to make it work?
And just a secondary question which is not related to may current question at all:
If I compile a lib with VS2013, can I use this lib in my VS2008 Project, or do I have to compile the lib with VS2008 too?
Thank you for your answers!
Microsoft doesn't recommend installing VS 2008 if you already have VS 2013 installed. In general they say:
We recommend that you install Visual Studio versions in the order in
which they were released. For example, install Visual Studio 2012
before you install Visual Studio 2013.
http://msdn.microsoft.com/en-us/library/ms246609.aspx
So, to answer your question: you probably should uninstall VS 2013, but you can install it again after installing VS 2008. Before doing that though it might be a good idea to clean the register as well as file leftovers from VS 2013 to avoid compatibility problems.
And yes, you can use 2008 compiler in 2013 version. There are a plenty of SO thread about it, e.g. :
Use Visual Studio 2012 and compile with older platform toolset?
How can I use Visual Studio 2010 with the Visual C++ 2008 compiler?
If I compile a lib with VS2013, can I use this lib in my VS2008
Project, or do I have to compile the lib with VS2008 too?
You have to compile this lib in VS 2008, if you want to use it with VS 2008.

Compile in Visual Studio 2013 for Visual Studio 2010 Redistributables

I have installed MS VS Express 2013 on my office computer, and compiled a DLL with it. Now when my colleague is trying to use it, she gets an error about a missing MSVCR120.DLL. We have found MSVCR100.DLL on her PC. I know that we can get MSVCR120.DLL from Microsoft. However
it will probably require admin rights, and only I have them in our team. I wonder if I can ask VS 2013 to compile the DLL so that it uses older version of redistributables? Or is installing the previous version of VS the only solution?
I found the solution — here: https://stackoverflow.com/a/1073772/674976. The distributable DLL can be statically linked to my DLL, thus removing the dependence. This is done in VS 2013 in Project Properties (Alt + F7) > Configuration Properties > C/C++ > Code Generation > Runtime Library, which should be set to Multi-threaded (/MT) from the default Multi-threaded DLL (/MD).
However, I wonder if by doing so I am actually still using redistributable DLLs of two versions and thus risk mixing the heaps and potentially causing memory allocation problems.
If someone suggests a better solution or a clear explanation why I should simply use Visual Studio 2010, I'll be happy to accept it is an answer.
Visual Studio 2013 can build Visual Studio 2010 C++ projects. To do this, you need to also have Visual Studio 2010 installed, because VS2013 will actually call the VS2010 C++ compiler.
What I have done to accomplish this is to create the solution and all the projects in Visual Studio 2010 and make sure that they build and run correctly. Then open them in Visual Studio 2013 and make sure to NOT upgrade the projects to VS2013.
Now you can use the latest tool and still build the VS2010 dlls that you need.

Installing Visual Studio 2010 AFTER Visual Studio 2012

I had Visual Studio 2012 installed on my new development computer and it worked fine. Without thinking I then installed VS2010 onto the computer which already had the 2012 install. 2012 continues to work correctly but 2010 cannot compile any of my previous working source code and it seems unable to locate any of the correct libraries.
For instance in a simple C++ hello world program I get the following error
fatal error C1083: Cannot open include file: 'iostream': No such file or directory
I have tried un-installing both, installing 2010 first then 2012 but the same problems still occur. I have also made sure it is using platform toolkit v100 but it seems to make no difference.
I have also tried repairing VS2010 to no avail.
Has anyone else experienced the same issues and if so how did they manage to fix it?
I'd guess it has something to do with VS2012's new v110_xp platform toolset which uses an SDK similar to 7.1. For my older projects that need 2003 Server and XP support I use that toolset now with VS2012 instead of the default toolset with VS2008 or VS2010 so I no longer need the older Visual Studios. It might solve your problem as well.

Can't Compile Solution in Debug Mode Because MSVCR100D.dll is Missing

I am running Microsoft Visual Studio Express 2012 for Windows Desktop on a 64 bit machine with windows 8.
I create a completely new Win32 Console Application (in C++) and accept the default options. I then build and run the solution in both debug and release modes and it works all find and dandy. Next I configure the include and library directories for the dynamic SFML library. I link to the debug and release .lib files and put the debug and release .dll files in the proper directories. I then add some simple code which uses the library, build and run the application in debug mode and I get this error: "The program can't start because MSVCR100D.dll is missing from your computer. Try reinstalling the program to fix this problem." If I build and run the application in release mode it works with no errors. (And yes I have the redistributables installed 32 and 64 bit.) Now from what I understand and according to this thread that .dll file is for debugging only and is not included in the redistributable package (which would explain why it doesn't work in debug mode). The answer says that developers have it installed with visual studio by default. This is obviously not the case as evidence from the error and I've reinstalled visual studio and restarted my computer twice now.
In conclusion, how do I simply compile my solution in debug mode without getting this error?
I'm afraid someone will mark this as a duplicate so here we go:
LINK - "...you appear to be linking to the debug version of the runtime, it is not normal to distribute apps linked against the debug version of the runtime."
Doesn't pertain to me because I'm not distributing this app, just trying to run it in debug mode.
LINK - "I compiled my program using Microsoft visual c++ 2010 Express Edition and tried to run it on another machine that did not have the same compiler."
This person get's the error when he runs what hes compiled on a different computer, not when actually compiling the application.
LINK - "If you get this error for your release build..."
I dont.
LINK - "You can compile your project in "Release"..."
My project is not ready to be released therefore I should compile my project in debug mode.
MSVCR100D.dll is the dll for Visual Studio 10, so somewhere something is depending on it (the SFML dlls?). Whatever you compile (in debug mode) with Visual Studio 2012 will require MSVCR110D.dll, which you should have available on your machine as part of the installation.
I suggest you build SFML yourself on your own version of Visual Studio, it's pretty easy. In fact, the binaries available on the site as part of the SFML 2.0 RC are rather old and you'll do yourself a huge favor by building from the latest sources, as a lot of fixes and improvement were applied in the meantime.
(Also, definitely use 2.0 instead of 1.6. The site is rather misleading, but on the SFML forums virtually everyone will recommend you use the last version)
This message generally states that the dll is referred to directly or indirectly in your application and is missing.
The 'D' at the end show us this is the Debug version of the file, this is DLL file is provided with the Visual Studio 2010 installation. So the MSVCR100D.dll would be provided with the installation of Visual Studio 2010.
Of course, you could be missing other versions 2008 (MSVCR90D) 2010 (MSVCR100D) 2012 (MSVCR110D) or the 2013 (MSVCR120D), each dll is provided according to the Visual Studio version.
There are a few ways to solve this:
Check to be sure that you're compiling all the components of your
project in Release mode. If this does not solve the issue continue
to the next steps.
You could solve this locally by installing Visual Studio 2010 on your
machine. This is not what I would recommend, but it would surely
overcome the issue
You could also download the file from this third party website and
copy it to your projects bin:
http://www.dll-files.com/dllindex/dll-files.shtml?msvcr100d
This option is the LEAST recommended option.
Run dependency Walker and see what file depends on the MSVCR100D.dll
and the try and fix that file in order to break your dependency. You can download depends here: http://www.dependencywalker.com/
Check to be sure that you're project is linking the correct version of
the CRT and any other libraries you may be using (e.g., MFC, ATL,
etc.)
Note: Installing the redistributables alone will NOT solve this problem, since the redistributables only contain the release version of the file MSVCR100.dll (notice no 'D')
MSVCR100D is part of the 2010 Visual Studio package - indicating that some components of your system are compiled with the older version of Visual Studio, so you will need to install the Visual Studio 2010 version - you can probably still develop with the 2012 version, just as long as [parts of] the 2010 is on the machine.
Or you need to recompile some components that your application depends on to use the 2012 (msvcr110d) libraries - if you have all the source code, that would be my preferrred method.