Node:Windows apps,
Next:Optimal hardware,
Previous:i286,
Up:Requirements
Q: Can I write MS-Windows applications with DJGPP?
A: Currently, you can only run DJGPP programs under Windows as DOS apps (i.e. inside the DOS Box). If you need to write true Windows apps, you will have to use auxiliary tools or another compiler. This section lists some of the possibilities.
RSXNTDJ is an add-on package for DJGPP which allows to develop Win32 programs using DJGPP development environment. It is essentially a cross-compiler targeted for Win32 (Windows 9X and NT) and Win32s (Windows 3.X + Win32s) platforms6; it supports DJGPP v2.x and includes debugging tools and an IDE. Beginning with version 1.60, RSXNTDJ is distributed under the terms of the GNU license (previous versions needed to be registered for a small fee if you wanted to develop commercial or shareware applications with it).
RSXNTDJ supports Win32 console, GUI, DLLs and bound programs (the latter can be run on DOS under the RSX extender, as well as on Windows). You can download RSXNTDJ via FTP. The latest version of the RSX IDE (called RSXIDE) is available from Rainer Schnitker's home page. Rainer's home page is also the place to look for the latest releases of RSXNTDJ, including beta releases.
RSXNTDJ version 1.31 was produced with GCC v2.7.2.1 and DJGPP v2.01. If you use it with later versions of GCC and DJGPP, it will need some tweaking; it is best to upgrade to RSXNTDJ v1.5 or later. Johan Venter wrote a HOWTO document that explains how to install and set up RSXNTDJ, and how to fix the various problems present in the current RSXNTDJ distribution. Make sure you read the RSXNTDJ HOWTO, before you try to install the package on your own; it will save you hours of banging your head against all kinds of weird problems, like missing files (due to truncated file names), linker error messages, inability to link C++ programs, etc.
In general, RSXNTDJ's support leaves a lot to be desired. Some problems take too long to fix, and response to user bug reports is slow. Even with the latest efforts by Johan Venter and others, you should expect to spend some time and effort installing and using the package. Another problem is that you depend on Microsoft SDK for the header files, and each new release of the SDK tends to break the patches to the header files required by RSXNTDJ.
These are disadvantages of RSXNTDJ with respect to other alternatives (see below); the most significant advantage is that you can use the entire DJGPP development environment. By contrast, other alternatives for free Win32 development usually provide less tools; in particular, Mingw32 provides only a few basic tools (like Make and GDB) beyond the compiler and Binutils. As a result, people who work with Mingw32 tend to use all kinds of different and subtly incompatible versions of shells, Make, etc. Cygwin has much more ports of GNU tools, but even Cygwin tool-chain doesn't have such a rich set of development tools all working together smoothly as DJGPP does. (Of course, if you don't mind developing with a minimal set of tools, this might not be a serious consideration for you.)
Here are some tips about RSXNTDJ:
patch
utility
fails.
There's an alternative to using patched MSSDK headers: Anders Norlander's WinAPI headers. These headers can be used as a drop-in replacement for the RSXNTDJ headers, and they include the functionality of Microsoft's headers. Beginning with version 1.5.1, the RSXNTDJ package includes a modified version of Anders Norlander's headers as part of the distribution.
djdevNNN.zip
package). Therefore, your best bet
would be to install RSXNTDJ in another directory, so that the headers
and libraries don't mix. Make sure that when you compile DJGPP
programs, the DJGPP include directories are searched before the
RSXNTDJ ones, and when you compile RSXNTDJ programs, the RSXNTDJ include
directories are searched first. Likewise, you should make sure the
compiler looks in the correct directories for libraries and the
crt0.o
startup module. When in doubt, add -v
to the
compiler's command line to see which directories it searches and in
which order, and what libraries does it link in.
One specific problems with conflicting headers is with the header
function.h
. Both DJGPP and RSXNTDJ have such a file, with
different contents.
stdio.h
header supplied with RSXNTDJ
defines several inline functions with the extern
qualifier, which
causes GCC to not compile them into the object file, and triggers
undefined references. The solution is to define the extern
symbol to an empty string in one of the source files which includes the
stdio.h
header.
cpp.exe
) is kept to
the PATH
environment variable, or copy the pre-processor into a
directory already on your PATH
. (Without this, the resource
compiler will not work.)
pestack
utility, allegedly due to insufficient size of the
default stack.
ld.exe
which comes with RSXNTDJ doesn't
print any message if you forget to link in libraries such as
libcomct.a
and libcomdl.a
. Instead, the produced
executables will die with SIGSEGV when run. Sometimes, forgetting to
#include
windows.h
also produces a program that crashes at
run time. You can use the stock DJGPP version of ld.exe
to see
the list of the missing functions, and then find out which libraries to
add to the link command line (use the nm
utility to find out
which libraries contain the required external symbols). The linker
supplied with RSXNTDJ is only required to link DLLs.
If RSXNTDJ doesn't suit your needs, you can use a few other free compilers which target Win32 platforms:
Cygnus GNU-Win32 tools
Mingw32 (Minimal GNU-Win32)
CRTDLL.DLL
, which is standard on Windows 9X and
Windows/NT) and doesn't require any additional DLLs like Cygnus ports
do; however, you lose the Posix layer. The basic package includes,
besides the compiler and Binutils, a few tools to compile resource files
and convert DLLs into lib*.a
wrappers. Since it doesn't use any
GPL'ed stuff except GCC and its subprograms, the programs produced by
Mingw32 are free.
A disadvantage of this package is a relative lack of development tools ported to Mingw32. The compiler, Binutils, Make, GDB, Textutils and Patch are available from the Mingw32 site, but ports of other utilities tend to be scattered around and not integrated together into a coherent package like what DJGPP or Cygwin present. This causes compatibility problems between the tools. It is possible to use the DJGPP tools where there are no equivalent Mingw32 ones, but you need to be aware of some incompatibilities, such as different methods of passing long command lines, lack of support for long file names on NT, etc.
More details, including ready binaries of ported utilities and
source-level patches to build other utilities with Mingw32, are
available on Mingw32 home page. For ports of
additional developemnt tools, visit Jan-Jaap van der Heijden's site.
Mingw32 has a mailing list.
Lcc-Win32 compiler and tools
Dev-C++ package
If you need on-line documentation of the Win32 API, you can find it as a Windows HLP file. Additional links to tutorials and other related information can be found on the bowman's home page.
The recommended book for learning Win32 programming seems to be Charles Petzold's Programming Windows: The Definitive Guide to the Win32 API, published by Microsoft Press.