Let the program written by vs2012/vs2013 run smoothly in XP

Source: Internet
Author: User

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 running on XP above "not a valid Win32 application"

In the vs2012/2013 version, its own C compiler cl.exe, if the direct use of CL A.C compiled, then the generated EXE in Vista and the above version of the direct operation is not a 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 direct compilation using the command line cl.exe:
First with CL A.C compile again, this time 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 appropriate project, select Properties, and in the project properties page under Configuration Properties, under General, change the platform toolset from Visual Studio v120 to Visual Studio 2013-windows XP (v120_xp ), and then rebuild the project once you are sure. 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 when running on a machine that does not have VC + + runtime, "MSVCR120D.DLL not found" will not 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 a way to compile a connection directly using Cl.exe and Link.exe:
Directly in the Cl.exe compile time or in the makefile inside the compiler parameters plus/MT can be.


For how to use a new project in vs2013:
Right-click the appropriate 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 "Multithreaded (/MT)", after determining, rebuild the project. So the resulting EXE file is statically compiled

Let the program written by vs2012/vs2013 run smoothly in XP

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.