Hi
How can I Compile windows netcat source code(netcat.c)under linux machine.
You can use MinGW compiler and Wine.
I would like to get nc.exe after I finished compilation.
http://joncraton.org/files/nc111nt.zip

Is it somthing like this?

root@kali:~/Desktop/nc# wine gcc -o nc1.exe netcat.c

As we know its easy to compile nc under linux

root@kali:~# wget http://sourceforge.net/projects/netcat/files/netcat/0.7.1/netcat-

0.7.1.tar.gz

root@kali:~# tar -xzvf netcat-0.7.1.tar.gz 


root@kali:~/netcat-0.7.1# ./configure

root@kali:~/netcat-0.7.1# make

root@kali:~/netcat-0.7.1#make install

Why would you need to use MinGW almost every linux distrubution has gcc available as part of the distro. Wine should not be needed.

Besides the rpm is also available on the site so again why use a Windows compiler on a Linux system?

Thanks Sir
I like to learn Compiling Windows environment code sometimes under linux Using the MinGW compiler and Wine.

If you have better idea to compile windwos netcat.c under linux
I will be appreciate it !

Just install the nc package on Linux. That is the native Linux version of netcat.

Thanks Sir
I have nc already in my linux(No problem) but I like to compile windwos source code like netcat under linux!
I think my question is clear.
MinGW cross compiler under linux

cd /root/.wine/drive_c/MinGW/bin

Well, it depends upon the dependencies of the package on Windows-specfic libraries and header files. I can only ask why you would want to do this? Experimentation? Need exact functionality that the netcat on Windows provides?

I have written many cross-platform applications an libraries that run identically on Linux and Windows. It is not necessarily a simple process. Also, Linux compilers will not create .exe files, but executable files - in this case it would be netcat, not netcat.exe, although changing the name wouldn't harm anything, or you could make sure that the Makefile created it as netcat.exe.

it would be netcat, not netcat.exe, although changing the name wouldn't harm anything, or you could make sure that the Makefile created it as netcat.exe.

I don't quite understand that sentence, but there is at least one interpretation of it that is very wrong. Linux executables are not the same as Windows executables, no matter what the extension is (with or without .exe). Linux uses ELF format (in the Unix/BSD tradition), while Windows uses PE format. These are completely different formats and unless you run under an emulation layer (like Wine in Linux, or Cygwin in Windows), there is no way to run one format in the other OS, AFAIK. Changing the extension does not do anything.

MinGW cross compiler under linux

The main problem really is to find a way to tell GCC to generate Windows code. And by Windows code, I really mean two things: it needs to use Windows libraries; and it needs to be packaged in PE format (.dll, .exe, etc.). The executable code itself is just dependent on the processor not the OS. I have very limited experience with setting up a cross-compilation environment. I just know that it's common for embedded systems and things like that where you can't really compile stuff on the target platform (it's too small), but in general, those are still Linux-to-Linux cross-compilations, just with a target different architecture and linking with specific libraries.

I would imagine that cross-compiling anything serious for Windows but under Linux would be quite a challenge, both in terms of dependencies and toolsets. But I think there is some hope, check out the mingw packages for Linux, and the MXE cross-compiler.

Thanks mike_2000_17,I think you understand me.
It just need to change Makefile in order to cross-compile.

list post-make

$ ls
Makefile  generic.h  getopt.o license.txt  netcat.c
doexec.c  getopt.c   getopt.obj  nc.exe       netcat.o
doexec.o  getopt.h   hobbit.txt  nc111nt.zip  readme.txt

Using x86_64-w64-mingw32-gcc

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.