From examining the source code of fortune.c from fortune-mod, it seems like significant porting effort would be required to make this compile natively on Windows. Cygwin is probably your best bet; all you'll have to do is ship the Cygwin runtime DLLs alongside the built EXE, and you won't have to run it inside a Cygwin terminal if you don't want to. Cygwin should provide 99% of the POSIX interop layer required to get it compiled. Failing that, there's a rewrite of Fortune in Python that will readily run on any platform.
You're welcome to try and port it yourself, but it won't compile with Visual Studio or MinGW unless you get rid of things like
#include <sys/*.h> and
fcntl.h from the source. These are POSIX-specific things that Windows does not natively support. See here -- file descriptors and sockets are treated very differently in Windows than on BSD/UNIX/Linux.
Cygwin, on the other hand, is designed to support exactly this type of thing, and it translates it under the hood into the equivalent Win32 calls. When compiling on Cygwin you may encounter some compile-time errors, but the severity and difficulty of these errors will be very minor compared to the difficulties encountered in porting it to compile on Visual Studio or MinGW.
cmd.exe shell environment for Microsoft Windows (at least on Windows NT and later) is not in any way related to DOS. I don't know why you would want to run anything on DOS unless it was absolutely necessary, and in this case, running DOS would make things harder, not easier.
Here are instructions for compiling on Cygwin:
Unpack the fortune-mod-9708.tar.gz to a folder
Makefile with your favorite text editor
Change line 49 to read:
Change line 55 to read:
make in the fortune-mod-9708 folder
Now you should have a compiled
fortune.exe binary. The following binaries should exist:
Now you can run
make install and it'll put everything in
/usr/local subdirectories. Or you can tweak the Makefile to install anywhere you want.
If you want to copy this tool to somewhere else, put the files
/usr/local/games, then take the entire
/usr/local folder, zip it up (or copy it somewhere), and run the games/fortune.exe as desired. You may need some additional DLLs from the cygwin bin directory; if you get errors when starting it, that's why. Put them in the same directory as
fortune.exe to get it working.
My response to your mention of DOS: