Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MinGW as a reliable 64-bit GCC compiler

I am worried about the reliability of the MinGW compiler for 64-bit, as an alternative to the Visual C++ compiler.

For example, assuming C++ code builds and runs perfectly under Linux using GCC 4.6.2, will the corresponding MinGW produce similarly reliable executables/libraries under 64-bit Windows?

Is Cygwin a better option in terms of reliablity? Is neither to the Visual C++ compiler?

like image 568
Nick Avatar asked Mar 30 '12 12:03

Nick


1 Answers

First, some misconceptions:

  1. MinGW(.org) does not provide a 64-bit version of its runtime. MinGW-w64 does, in addition to their 32-bit CRT. They are also working on ARM support. And support various additional APIs (Win32 and others).

  2. Cygwin <-> MinGW-w64: Cygwin does not use the MS CRT (msvcrt.dll). It instead inserts a POSIX compatibility layer in between your Cygwin app and the system's OS libraries (kernel32.dll, ntdll.dll, etc.), namely cygwin1.dll.

On to the question then...

I have found the MinGW-w64 compilers very good, and GCC 4.6 and above (actually, 4.5.1 and above) are very capable of producing good 64-bit code for Windows. Please remember that MinGW provides essentially the same C API as msvcrt.dll, so go to msdn.com for documentation (and be sure to look at the "MSVC++ 2003" version of documentation, some functions differ with the newer runtimes), do not think that because it's GCC, glibc documentation suddenly applies to Windows. Your code will have to be cross-platform. Also note that sizeof(long)!=sizeof(T*) on x64 Windows. A commonly encountered error when porting *nix or x86 Windows code to x64 Windows.

like image 184
rubenvb Avatar answered Nov 09 '22 00:11

rubenvb