Native Windows system has poor support for C and POSIX currently. Maybe MS has noticed this situation and begins converting it. There are two methods to utilize POSIX under Windows.
1.windows subsystem for linux
https://docs.microsoft.com/en-us/windows/wsl/install-win10
At the present, the following Linux distributions are supported.
Ubuntu 16.04 LTS
Ubuntu 18.04 LTS
OpenSUSE Leap 15
OpenSUSE Leap 42
SUSE Linux Enterprise Server 12
SUSE Linux Enterprise Server 15
Kali Linux
Debian GNU/Linux
Fedora Remix for WSL
Pengwin
Pengwin Enterprise
Alpine WSL
2.Cygwin/Cygwin64
It implements POSIX APIs using Windows functions. Both the installation and update are easy. It contains rich functions which are the same as under Linux. MS is said to only support C89 standard. If you’d like to use features of C99/C11 or the latest GCC/Clang compiler, Cygwin may be your choice.
If u compile under Cygwin, your program will rely on cygwin.dll which has the license similar to GPL. So u need to release your source code if u distribute DLL library stripped from Cygwin. And you have to pay to avoid this.
https://preshing.com/20141108/how-to-install-the-latest-gcc-on-windows/
The commands I prefer are as follows:
C:\cygwin64>setup-x86_64.exe -q -P wget -P gcc-g++ -P make -P diffutils -P libmpfr-devel -P libgmp-devel -P libmpc-devel
Compling C Program not under POSIX environment on Windows
The answer is MinGW(Minimalist GNU for Windows), which provides a standard C compiler and some utilities. Meanwhile, Accompanying Msys provides other tools such as shell.
IDEs for MinGW on Windows: Code:blocks, Eclipse
As MinGW lacks precompiled libraries, u may have to download and compile source code of needed libraries manually, while using other package manager, u just need to input a single command.
References:
21st Century C
原生Windows系统对C和POSIX支持不佳。文中介绍两种在Windows下使用POSIX的方法,一是Windows子系统Linux,支持多种Linux发行版;二是Cygwin/Cygwin64,用Windows函数实现POSIX API。还提到在非POSIX环境编译C程序可用MinGW,同时介绍了其IDE及存在的问题。
826

被折叠的 条评论
为什么被折叠?



