Bash on Ubuntu on Windows (WSL), CygWin, MinGW
I'm currently using windows 8.1 and was looking to install GCC. I found out that the ways to do this is through MinGW and CygWin (the most popular). Now I came up on the Windows Subsystem for Linux (WSL)and Bash offered on Windows in Windows 10.
Question 1. whether it is possible to have GCC installed through the Bash in Windows 10, and will it work as it does on a Linux distribution. Say you have a 'helloworld.c' file, and if I do,
> gcc helloworld.c
$ ./a
in the bash would i get the output (assume the contents of 'helloworld.c' to be simple - a cout
statment.)
Question 2. If it is possible then, which of the methods is preferred to use GCC on Windows. That is, a)MinGW or CygWin b)Bash on Linux on Windows. Because based on what I understood on what I read, CygWin and MinGW causes some dependencies on programs developed on them.
Question 3. If you have read this far then please fill in my gap in understanding about CygWin and MinGW. That is if I use it only for compiling and running pieces of code and not application developement, it doesnt matter which of these I use, am I right? Because the code (written in C or FORTRAN), will compile and execute the same irrespective of the system, am I right?
Context. I am a student working on numerical computations (Computational Fluid Dynamics) and my main work is to develop and run CFD codes in FORTRAN. What I want to do is work on the computational code (for which we use FORTRAN mainly) on my laptop which runs on Windows. And I am not looking to develop applications or softwares for either Windows or Linux at the moment. But I'd still like to know how things work and which is the best option. Please explain in detail. Thank you.
To answer your first question, yes, you can do that compile under WSL.
To answer your other questions, let's look at MinGW. This is what the Wikipedia entry for MinGW says:
MinGW was forked from version 1.3.3 of Cygwin.[5] Although both Cygwin and MinGW can be used to port Unix software to Windows, they have different approaches:[16] Cygwin aims to provide a complete POSIX layer comprising a full implementation of all major Unix system calls and libraries. Compatibility is considered higher priority than performance. On the other hand, MinGW's priorities are simplicity and performance. As such, it does not provide certain POSIX APIs which cannot easily be implemented using the Windows API, such as fork(), mmap() and ioctl().[16] Applications written using a cross-platform library that has itself been ported to MinGW, such as SDL, wxWidgets, Qt, or GTK+, will usually compile as easily in MinGW as they would in Cygwin.
Windows programs written with Cygwin run on top of a copylefted compatibility DLL that must be distributed with the program, along with the program's source code. MinGW does not require a compatibility layer, since MinGW-based programs are compiled with direct calls to Windows APIs.
(https://en.wikipedia.org/wiki/MinGW)
This is what the MinGW web page (http://www.mingw.org) says:
MinGW, a contraction of "Minimalist GNU for Windows", is a minimalist development environment for native Microsoft Windows applications.
MinGW provides a complete Open Source programming tool set which is suitable for the development of native MS-Windows applications, and which do not depend on any 3rd-party C-Runtime DLLs. (It does depend on a number of DLLs provided by Microsoft themselves, as components of the operating system; most notable among these is MSVCRT.DLL, the Microsoft C runtime library. Additionally, threaded applications must ship with a freely distributable thread support DLL, provided as part of MinGW itself).
MinGW compilers provide access to the functionality of the Microsoft C runtime and some language-specific runtimes. MinGW, being Minimalist, does not, and never will, attempt to provide a POSIX runtime environment for POSIX application deployment on MS-Windows. If you want POSIX application deployment on this platform, please consider Cygwin instead.
I am familiar with WSL and Cygwin more than MinGW. From what I know, MinGW is more targeted to producing reasonably portable, high-performance Windows binaries whereas Cygwin is more targeted to Unix users (or those wanting to port applications that were written for Unix/POSIX) who want a Unix-like environment under Windows with all the trimmings. As you indicated, Cygwin programs at least used to be less easily distributable to others who don't have Cygwin installed (due to license considerations, but see the link below). MinGW programs run as native Windows programs using undocumented Windows native libraries. WSL binaries don't run under Windows by themselves; they only run in the WSL environment (or possibly native Linux systems). WSL maps Linux kernel calls to Windows kernel calls, whereas Cygwin implements Unix/Posix library calls. WSL relies on a real Linux distribution to provide it's environment, whereas Cygwin relies on its own environment. (WSL has an advantage in that it will run existing binaries without recompilation.) I don't think any of this is too important to you, because you're not planning on distributing your binaries. You want high performance. According to Wikipedia, MinGW is higher performance than Cygwin, but it's also 32-bit which may be a problem with your applications. There is a 64-bit environment similar to MinGW but it's a different project.
An important consideration is whether you want to write Windows code or Unix/Linux/POSIX code. MinGW is for developing Windows applications using Windows APIs (although you can fold in some limited POSIX support); WSL and Cygwin are for developing Unix/Linux/POSIX applications. This matters for portability purposes. But if you are developing the type of programs I think you are, nearly all straight computations and very little fancy I/O, it may just boil down to personal preference or convenience. If you can come up with a small representative program that takes a significant amount of time and try running it under each environment, you can find out which has the best performance. That is going to depend I think on your own mix of operations.
See also What is the difference between Cygwin and MinGW?
链接地址: http://www.djcxy.com/p/95088.html上一篇: “到下载的CSV文件