原文:https://www.kechuang.org/t/81211
Visual C++的正统做法是使用DLL版本运行库。运行库分发方法有两种,一种方法是直接附带DLL,另一种方法是使用vcredist_x86.exe。
如果不想使用DLL版本运行库,而是想静态编译的话,可以更改项目属性,将Release版/MD开关改为/MT,Debug版/MDd开关改为/MTd。但是静态编译有限制,不能跨DLL申请或释放堆内存,也不能使用/clr编译为托管程序集。
Visual C++ 2015微软作了一个死,导致在Windows XP/7/8.1等老系统上需要附带一堆DLL。如果不想附带这么多DLL,有三种方法:
静态编译
使用vcredist_x86.exe
改用Visual C++ 2013
Visual C++ 2005/2008(以2008为例)
Release版:C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.CRT
Debug版:C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\redist\Debug_NonRedist\x86\Microsoft.VC90.DebugCRT
以Release为例,一共有四个文件:
Microsoft.VC90.CRT.manifest——并列配置清单文件,必须附带
msvcr90.dll——C运行库
msvcp90.dll——C++运行库
msvcm90.dll——C运行库托管(.NET)导入库
其它文件夹还有:
MFC/ATL相关运行库
Visual C++ 2010/2012/2013(以2012为例)
Release版:C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\redist\x86\Microsoft.VC110.CRT
Debug版:C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\redist\Debug_NonRedist\x86\Microsoft.VC110.DebugCRT
以Release为例:
msvcr110.dll——C运行库
msvcp110.dll——C++运行库
vccorlib110.dll——应用商店运行库(VC++2012/2013)
其它文件夹还有:
vcomp110.dll——OpenMP运行库
vcamp110.dll——C++AMP运行库(VC++2012/2013)
MFC/ATL相关运行库
Visual C++ 2015
VC++2015对C/C++运行库进行了巨大的改造,分成了两部分:C/C++运行库和Universal CRT DLLs。在Windows XP/7/8.1上需要第一部分和第二部分,在Windows 10上仅需要第一部分。
C/C++运行库
Release版:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\redist\x86\Microsoft.VC140.CRT
Debug版:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\redist\Debug_NonRedist\x86\Microsoft.VC140.DebugCRT
vcruntime140.dll——C运行库
msvcp140.dll——C++运行库
vccorlib140.dll——应用商店运行库
concrt140.dll——并发运行库
其它文件夹还有:
vcomp140.dll——OpenMP运行库
vcamp140.dll——C++AMP运行库
MFC/ATL相关运行库
Universal CRT DLLs(获取这些DLL需安装Windows 10 SDK 10586+)
Release版:C:\Program Files (x86)\Windows Kits\10\Redist\ucrt\DLLs\x86
Debug版:C:\Program Files (x86)\Windows Kits\10\bin\x86\ucrt
Release版DLL需要全部附带
Debug版需要使用ucrtbased.dll替换ucrtbase.dll
api-ms-win-core-console-l1-1-0.dll
api-ms-win-core-datetime-l1-1-0.dll
api-ms-win-core-debug-l1-1-0.dll
api-ms-win-core-errorhandling-l1-1-0.dll
api-ms-win-core-file-l1-1-0.dll
api-ms-win-core-file-l1-2-0.dll
api-ms-win-core-file-l2-1-0.dll
api-ms-win-core-handle-l1-1-0.dll
api-ms-win-core-heap-l1-1-0.dll
api-ms-win-core-interlocked-l1-1-0.dll
api-ms-win-core-libraryloader-l1-1-0.dll
api-ms-win-core-localization-l1-2-0.dll
api-ms-win-core-memory-l1-1-0.dll
api-ms-win-core-namedpipe-l1-1-0.dll
api-ms-win-core-processenvironment-l1-1-0.dll
api-ms-win-core-processthreads-l1-1-0.dll
api-ms-win-core-processthreads-l1-1-1.dll
api-ms-win-core-profile-l1-1-0.dll
api-ms-win-core-rtlsupport-l1-1-0.dll
api-ms-win-core-string-l1-1-0.dll
api-ms-win-core-synch-l1-1-0.dll
api-ms-win-core-synch-l1-2-0.dll
api-ms-win-core-sysinfo-l1-1-0.dll
api-ms-win-core-timezone-l1-1-0.dll
api-ms-win-core-util-l1-1-0.dll
api-ms-win-crt-conio-l1-1-0.dll
api-ms-win-crt-convert-l1-1-0.dll
api-ms-win-crt-environment-l1-1-0.dll
api-ms-win-crt-filesystem-l1-1-0.dll
api-ms-win-crt-heap-l1-1-0.dll
api-ms-win-crt-locale-l1-1-0.dll
api-ms-win-crt-math-l1-1-0.dll
api-ms-win-crt-multibyte-l1-1-0.dll
api-ms-win-crt-private-l1-1-0.dll
api-ms-win-crt-process-l1-1-0.dll
api-ms-win-crt-runtime-l1-1-0.dll
api-ms-win-crt-stdio-l1-1-0.dll
api-ms-win-crt-string-l1-1-0.dll
api-ms-win-crt-time-l1-1-0.dll
api-ms-win-crt-utility-l1-1-0.dll
ucrtbase.dll
VC++6.0的DLL
msvcrt.dll——C运行库
msvcirt.dll——上古C++使用的iostream运行库
msvcp60.dll——标准C++运行库
VC++.NET2002/2003的DLL(以VC++.NET2003为例)
msvcr71.dll——C运行库
msvcp71.dll——C++运行库
联系客服