Translated from http://blog.csdn.net/asanscape/article/details/38752655
For Microsoft to sell its own platform, applications written by VS2012 and VS2013 under the default configuration can only run on Vista/win7/win8. Fortunately, the setup entries for the Build XP program are also preserved. XP and Win2003 users are still a lot of existence, our program software release cannot but consider them.
1. Project menu, Project properties, configuration Properties, general, Platform toolset, select "Vs2013windowsxp (V120_XP)";
2. Use of general->mfc, configuration Properties, item properties, Project menu, and choose to use MFC in a static library;
3. Console or Windows (depending on your project type), System--subsystem--systems-------project Properties-------------The second item is set to 5.01.
4. C/c++-> code generation-run library, select "Multithreaded Debugging (/MTD)";
5. It is also necessary to have at least Update3 (or 4), which I have not verified, because I am directly installing the VS2013 with Update3.
The above is OK. Shortcomings still have, for example, statically compiled exe than normal dynamic is much larger, at present I have not yet tried the dynamic compilation in XP can run the method,--but this does not matter, because the VS2013 version is so high, the customer's computer is difficult to bring with its own runtime, even if you dynamically compile, The software is also released with the runtime, but only one copy of the runtime is required for multiple programs.
In addition, I use the above method in the actual large project, still have the error phenomenon to occur. Let's study it later. In general, the above method is possible.
In addition to the online found this post, said very detailed, including non-IDE command-line compilation, together with the following:
Problem one: Compiled EXE run on XP above the hint "not a valid Win32 application" in the vs2012/2013 version, its own C compiler cl.exe, if directly using CL A.C compiled, then generated EXE placed in Vista and the above version directly run no problem, but on XP will come out "is not a valid Win32 application" error prompt. This is because the C compiler that comes with vs2012/2013 by default will only support Windows systems with Vista and above by default for EXE generation. Workaround: For the use of the command line cl.exe Direct compilation: first compiled with CL A.C, this will generate A.exe and a.obj two files, at this time, then execute link b.obj/subsystem:console, 5.01, it will link a new a.exe out, at this time the EXE can be run on XP. Compared to VS2010 and the previous version of the compiler compiled, there will be a second step of the link process, the following parameters are also easy to understand, subsystem,5.01, here is 5.01 refers to the Windows kernel version number, 5.01 represents Windows with SP1, That is, this EXE can be executed in Windows Win2000 SP1 and above. Of course, this place has a lot of parameters behind the/subsystem, the above console,5.01 refers to the command line program, if there is a GUI window program, change to windows,5.01 can. Attention!! The 5.01 here must not be taken for granted to 5.0 to become Windows 2000 without SP1 version, in fact, 5.0 is not recognized by the vs2013 compiler, Will be reported to the police do not recognize 5.0, will follow the default without 5.01 of the way to compile, so that you can not run in the system under the vista of the generated exe. For how to use a new project in vs2013: Right-click the project, select Properties, and in the project properties page under "General" under "Configuration Properties," change "Platform Toolset" from "Visual Studio (v120)" to "Visual Studio 2013-windows XP (V120_XP) ", after you are sure, rebuild the project. Of course, in this way, it can only be used in WinXP and above the version of the system to run.
Problem two: exe compiled with vs2010/2012/2013 on the machine that does not install VC + + runtime prompts "MSVCR120D.DLL not found" to run this is an old problem, nothing more than the runtime dynamic compilation and static compilation of the problem. DLL dynamic loading, it is a good thing, it can reduce the volume of the generated EXE file, but the disadvantage is that if the corresponding system environment variables or EXE in the directory where the required DLL files cannot be found, the program will refuse to execute. and static compilation is to all the required libraries are statically compiled into the EXE file, so that can be run on all system platforms, but it also has a drawback, is that the resulting EXE file because the code has been a part of the library, So the volume will be relatively dynamically compiled EXE large (how much depends on the contents of the library to determine). Workaround: For the direct use of cl.exe and link.exe to compile the connection: directly in the cl.exe compile time or in the makefile inside the compiler parameters plus/MT can.
For how to use a new project in vs2013: Right-click the project, select Properties, and in the project properties page under "Configuration Properties" under "C + +" under "code Generation", the default "multithreaded debug DLL (/MDD)", Changed to "Multithreading (/MT)", after determining , rebuild the project. The resulting EXE file is statically compiled.
Visual Studio lets programs written with vs2012/vs2013 run smoothly in XP (GO)