VS2013 compiled in C + + written Win32 Program compatibility issues

Source: Internet
Author: User

Recently in the use of VS2013 to write programs, the compiled EXE on someone else's computer run will be missing MSVCP file can not run the situation. Search the Internet for a moment, the problem is as follows:

C + + Program runtime requires the support of the standard library, Windows Msvcrt.dll (c run-time) and MSVCP (c + + runtime), Linux for libc.so and libstdc++.so. Windows XP with VC 6.0 running, if the VC 6 compiled words can run normally.

The VS 2013 runtime must be installed with an additional installation, i.e. vc2013 redistribution. Or you can do it like you do now, compile-time select/MT, when the runtime will be directly included in your execution file, you can run on any machine. This is also why your files are becoming very large, because the implementation of the standard library is included.
Workaround: 1, choose release instead of debug when building the solution.

2, compile-time select/MT, when the runtime will be directly included in your execution file, you can run on any machine.
Specific actions:

the difference between MD (d), MT (d) Compilation options 1, the location of the compilation options

Take VS2005, for example, to open this way:

1 Open the Project's Property Pages dialog box

2) Click on the left-C + + section

3) Click Code Generation Section

4 the right sixth Line runtime library item 2, the meaning of each setting option represents

Compilation options

Contains

Statically linked Lib

Description

/md

_MT, _dll

MSVCRT.lib

Multithreaded, release, DLL version of the runtime library

/MDd

_DEBUG, _MT, _dll

MSVCRTD.lib

Multithreaded, Debug, DLL version of the runtime library

/mt

_mt

LIBCMT.lib

Multithreaded, release version of the Run-time library

/MTd

_DEBUG, _MT

LIBCMTD.lib

multithreaded, debug version of the Run-time library

To put it simply:

(1)/MD, which means that the Run-time library is provided by the operating system with a DLL and is not integrated in the program.

(2)/MT, which means that the Run-time library is integrated by programs.

ii. selection of/MD and/MT 1, why choose/MD, do not choose/MT.

(1) The program does not need static link Run-time library, can reduce the size of the software;

(2) All modules are used/MD, using the same heap, there is no a heap application, b heap release problem. 2, why choose/MT, do not choose/MD.

(1) Some systems may not have the program required version of the Run-time library, the program must put the Run-time library static link. 3, multiple modules, you must select the same Run-time library. Third, the choice of/mt need to solve the problem of heap space release

Different modules have a C run-time library code, or there is no C run-time library, resulting in each module will have their own heap. If you apply for space in the A heap, there will be a crash in the B heap, and you must release it in module A for the space requested by module A.

The DLL for the attachment (download address: Http://files.cnblogs.com/cswuyg/Test_MD_and_MT.rar) and the Dlluser code, taking STL string as an example, verify the problem by modifying the compilation option. (A string needs to release the original space when it is assigned, and then apply for new space to store the new content.) )

IV. Reference materials

1, Microsoft about MT, MD and so on detailed introduction

Http://msdn.microsoft.com/en-us/library/2kzt1wy3 (v=vs.71). aspx

2, do not appear a module application, b module release of the situation

Http://www.cnblogs.com/minggoddess/archive/2010/12/15/1907179.html

3. What are the runtime library versions

Http://www.cppblog.com/MichaelLiu/articles/10607.html

4. Discussion on heap space release on CSDN

Http://topic.csdn.net/t/20010112/09/57983.html

Http://topic.csdn.net/t/20031009/17/2338051.html

Http://topic.csdn.net/u/20090502/00/bf1602e3-ddf5-49b0-af81-8a23383f9ddc.html

http://blog.csdn.net/blz_wowar/article/details/2176536

5, different modules of different heaps

Http://www.cnblogs.com/WengYB/archive/2011/08/18/2144727.html

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.