Compile Netcat on Windows using MinGW

Last Modified: Tue, 15 Jan 2019 18:01:58 +0000 ; Created: Tue, 08 Sep 2009 16:58:50 +0000

I wanted a way to compile Netcat on Windows using MinGW so I could have a version without the GAPING_SECURITY_HOLE option (-e command line option). This helps to avoid the annoyance of anti-virus tools reporting it as a virus/trojan and also gives me a binary I know isn't infected with something.

Doing so on Windows is a real pain since there isn't a straight forward make file for MinGW. It seemed mostly geared at Microsoft VC.

Just copy and paste the following text into a "makewin.cmd" file in the same directory as the source. A good place to get source for Windows is (this also includes a binary for Netcat for Windows but the -e option is still turned on).

I also have a build of Netcat (nc.exe) that you can download here.
A copy of the source code with makewin.bat is here. This only has the source and build files, no executable.
In addition you can find other sites that provide mirrors at

You'll need MinGW with gcc ( GCC-8.2.0-3) 8.2.0. Modify the paths in the batch script as needed and run it. You should get a nc.exe file if all went well.

@REM	Build script to compile Netcat on WIN32 using MinGW
@REM	Rodney Beede	(
@REM	2019-01-15
@REM	Tested with gcc ( GCC-8.2.0-3) 8.2.0

@REM	Adjust PATH so necessary dll's are accessible
SET PATH=%PATH%;c:\MinGW\bin

SET COMPILER=c:\MinGW\bin\gcc.exe
SET LIB_DIR=c:\MinGW\lib


del *.o
del nc.exe




@REM Note that the -l libraries MUST come at the very end or linking will fail
"%COMPILER%" getopt.o doexec.o netcat.o --output nc.exe -Wl,-L"%LIB_DIR%",-lkernel32,-luser32,-lwinmm,-lws2_32