Mingw always uses the msvcrt. dll, vc8, 9, and 10 APIs of vc6 (only limited to C Runtime). What should I do? For example, the minimum requirement of boost for mingw is msvcrt 7.0
1. mingw system default situation
Mingw selects the msvcr version based on the macro msvcrt_version,If this parameter is not specified, the API of vc7 is used by default (Bug, mingw is connected to msvcrt. DLL by default, although it is not much different from msvcr70.dll)
Mingw 4.8The (w32api-4.0.3-1) has the following definition, depending on the version of the target operating system to determine the runtime (you still need to manually specify a specific version of msvcrt when linking) file/mingw/include/_ mingw. h
/* * We need to set a default MSVCRT_VERSION which describes the MSVCRT.DLL on * the users system. We are defaulting to XP but we recommend the user define * this in his config.h or Makefile file based on the minimum supported version * of OS for his program. * ME = 600 * XP = 710 * VISTA = 800 * WIN7 = 900 * WIN8 = 1010 */#ifndef MSVCRT_VERSION#if _WIN32_WINNT >= _WIN32_WINNT_WIN8#define MSVCRT_VERSION 1010#elif _WIN32_WINNT >= _WIN32_WINNT_WIN7#define MSVCRT_VERSION 900#elif _WIN32_WINNT >= _WIN32_WINNT_VISTA#define MSVCRT_VERSION 800#elif _WIN32_WINNT >= _WIN32_WINNT_WINXP#define MSVCRT_VERSION 710#elif _WIN32_WINNT >= _WIN32_WINNT_WIN2K#define MSVCRT_VERSION 700#elif _WIN32_WINNT >= _WIN32_WINNT_WINME#define MSVCRT_VERSION 600#else#define MSVCRT_VERSION 700#endif /* _WIN32_WINNT >= _WIN32_WINNT_WINME */#endif /* ndef MSVCRT_VERSION */
Mingw 4.7 and earlierMsvcr version is selected through macro _ msvcrt_version. 2. mingw uses a later version of VC runtime to edit the spec file (refer to the http://www.mingw.org/wiki/HOWTO_Use_the_GCC_specs_file) to generate the default GCC spec File
Gcc-dumpspecs> <mingw-root>/lib/GCC/mingw32/<gcc-version>/specs
Modify CPP and libgcc In the specs file (marked in red)
* CPP:-dmsvcrt_version = 0 x 0710% {POSIX:-d_posix_source }%{ mthreads:-d_mt }%{ pthread:-d_reentrant }% {! No-pthread :}* libgcc: % {mthreads:-lmingwthrd}-lmingw32% {shared-libgcc:-lgcc_s }% {! Shared-libgcc:-lgcc_eh}-lgcc-lmoldname71-lmingwex-lmsvcr71
Note: This method can only be changed from msvcrt. DLL to msvcr70.dll or msvcr71.dll to link a later version of msvcr dynamic library, for example, msvcr90.dll. The system prompts that _ findfirst cannot be located on msvcr90.dll. The cause of this problem is that mingw links libmingwex. a library in the Link stage, which is compiled in the vc6 environment and depends on msvcrt. dll. Therefore, you also need to compile multiple pieces of mingwex in the vc8, 9, and 10 environments. here we can use vc8 as the environment to compile a version, because vc8 is much changed compared with the vc71 API, 10.
3. recompile libmingwex.Download the http://iweb.dl.sourceforge.net/project/mingw/MinGW/Base/w32api/w32api-4.0.3/w32api-4.0.3-1-mingw32-src.tar.lzma and unzip it; modify the w32api-4.0.3-1.mingw32-src/makefine. In to specify the version of the VC Runtime (vc8 is specified here, and the minimum operating system version requirement is changed to XP)
All_cflags = $ (cflags) $ (primary des)-dntddi_version = 0x05010000-dmsvcrt_version = 800
The findfirst findnext definition in the header file of mingw WIN32API 4.0.3-1 is incorrect. You need to modify and replace wchar. h and IO. H. Click here to download
Then re-compile
./Configuremake
Copy the compiled ligmingex. A to the mingw/lib directory, and add a suffix. It depends on vc8 and is renamed libmingex80.a. Modify the spec file and change-lmingwex to the new file above.
* Libgcc: % {mthreads:-lmingwthrd}-lmingw32% {shared-libgcc:-lgcc_s }% {! Shared-libgcc:-lgcc_eh}-lgcc-lmoldname80-lmingwex80-lmsvcr80
Then compile a file at will, and run the program will report the following problem. msvcr90.dll cannot be found to force copy a msvcr90.dll to the program directory, but r6034 is reported during running. For details, see this problem, manually create a manifest file under the generated target EXE directory. File Name: program name. suffix. manifest content (version needs to be modified according to your system's msvcr version ):
<? XML version = '1. 0' encoding = 'utf-8' standalone = 'Yes'?> <Assembly xmlns = 'urn: Schemas-Microsoft-com: ASM. v1 'manifestversion = '1. 0'> <trustinfo xmlns = "urn: Schemas-Microsoft-com: ASM. v3 "> <Security> <requestedprivileges> <requestedexecutionlevel = 'asinvoker 'uiaccess = 'false'/> </requestedprivileges> </Security> </trustinfo> <dependency> <dependentassembly> <assemblyidentity type = 'win32 'name = 'Microsoft. vc90.crt 'version = '9. 0.21022.8 'processorarchitecture = 'x86 'publickeytoken = '1fc8b3b9a1e18e3b'/> </dependentassembly> </dependency> </Assembly>
Note: There is a saying on the internet want to link to a higher version of msvcr, just do not link any mingw standard library at compilation, only link msvcr and GCC (see the http://stackoverflow.com/questions/3402252/how-to-link-against-msvcr90-dll-with-mingw-gcc for details), but the actual results are as follows:
$ Gcc. c-nostdlib-lmsvcr80-lgccd:/msys/mingw/bin /.. /lib/GCC/mingw32/4.8.1/libgcc. A (_ main. o ):(. text + 0x5a): Undefined reference to 'atexit'collect2.exe: Error: LD returned 1 exit status
Mingw uses msvcr90.dll