We use the Visual C ++ xxxx (XXXX stands for 2010, etc.) compiler to compile the application so that it can run on the target computer without the Visual C ++ XXXX compiler installed, the corresponding Microsoft Visual C ++ XXXX Runtime Library must be installed on the target computer. After installation, runtime support for C, standard C ++, ATL, MFC, OpenMP, and msdia class libraries will be provided. For example, to run an application written in Visual C ++ 2008, you must install Microsoft Visual C ++ 2008 SP1 redistributable package on the target computer.
When we search and download Microsoft Visual C ++ XXXX redistributable on Microsoft's official website, we will find many different versions, the following uses Microsoft Visual C ++ 2008 redistributable as an example to describe common versions.
Common Microsoft Visual C ++ 2008 redistributable versions are as follows:
Microsoft Visual C ++ 2008 SP1 redistributable package (x86)
Microsoft Visual C ++ 2008 SP1 redistributable package (x64)
Microsoft Visual C ++ 2008 redistributable package (x86)
Microsoft Visual C ++ 2008 redistributable package (x64)
X86 indicates that it is applicable to 32-bit systems and x64 indicates that it is applicable to 64-bit systems.
SP1 is equivalent to the version number, indicating the latest version. Therefore, we should install the latest version: SP1.
Note: The 64-bit operating system can run both 32-bit applications and 64-bit applications, so on the 64-bit operating system, choose whether to install the x86 or x64 visual c ++ Runtime Library Based on whether the application is 32-bit or 64-bit.
If you run an application published by Microsoft Visual C ++ XXXX on a computer that does not have the Microsoft Visual C ++ XXXX Runtime Library installed, the following error is reported: the application cannot be started, because the application settings are incorrect, reinstall the application to fix this problem. Therefore, when you start a program, you can determine whether to install the corresponding visual c ++ Runtime library based on the error message.
In fact, we can also run the Visual C ++ XXXX application on the target computer without installing the Visual C ++ XXXX Runtime Library. The solution is only to use static links when compiling and linking an application. You can set the use MFC in a static library attribute, as shown in:
By default, all projects created using VC use dynamic links, that is, use MFC in a shared DLL.
When you set use MFC in a static library, the link application is compiled using static links. Although the target computer running the program does not need to install the corresponding visual c ++ Runtime Library, the static link will load the corresponding library files used to the generated application, the size of the generated executable file is significantly increased. More system resources are required during execution, and more time is consumed when the memory is loaded. (For example, I wrote a simple MFC Dialog Box program in Visual Studio 9.0. When dynamic links are used, the program size is 2.16 kb, and when static links are used, the program size is mb ).
Select static or dynamic link based on the actual situation. However, the dynamic link is usually selected and the corresponding visual c ++ Runtime library is installed on the target computer where the program runs.