FreeDOS: Installing and running DJGPP.
"DJGPP is a complete 32-bit C/C++ development system for Intel 80386 (and higher) PCs running DOS. It includes ports of many GNU development utilities. The development tools require an 80386 or newer computer to run, as do the programs they produce. In most cases, the programs they produce can be sold commercially without license or royalties." This is how they describe the product on the DJGPP page of Delorie. You can also call it the port of the GNU compiler collection from Unix-like systems to DOS and Windows.
The following tutorial describes the installation of DJGPP 2.0.5. The DOS platform used is FreeDOS 1.3 RC5, the way to proceed on MS-DOS or other DOS systems should be similar. The tutorial only covers the basics (C and C++ development using RHIDE), without condidering special libraries (like Allegro), or other GNU programming languages (FORTRAN, ADA, Pascal...) that may be installed on the top of DJGPP.
Downloading DJGPP.
DJGPP is a really huge project, composed of a large number of packages for different platforms. Which packages (individual .zip files) you need depends on what you intend to use the software for. Browsing the files and manually choosing what to install would be rather hard, I guess. Fortunately, Delorie offers a lots simpler way to find what you need. On their DJGPP Zip File Picker page, you have the possibility to fill out a form and, based on your selections, the web application will generate a page with the links to the corresponding .zip files. In the first part of the form, you can choose if you want to build or only to run DJGPP applications (obviously to build them in our case), choose the operating system (DOS in our case), choose if you want to download the documentation files and select which programming languages you want to be installed: C, C++, Objective C and Assembler in my case.
![]() |
Further down on the form, you can select an editor/IDE (RHIDE, similar to Borland's IDE works fine), choose if you want the text-mode GNU debugger (actually not needed if you install RHIDE that includes a debugger) and make your selections for the extra stuff shown on the page (note, that the components shown are only the most popular ones; to view them all, visit the download site itself). I selected all of them, except the sources (I did not yet try out anything of these, so I can't say how well or not they work).
![]() |
The following screenshot shows the packages (.zip files) that the file picker application has selected. Note that files with a name ending in -b are binaries; those ending in -d are documentation.
![]() |
Download the files and (the simplest way to proceed, I would say) burn them onto a CDROM (aka make an ISO to be used in your virtualization software or virtual CD-drive) in order to access them on your FreeDOS machine.
Installing DJGPP.
When unzipping the different packages, please be aware of the following:
- Unzip all files to the same directory (e.g. C:\DJGPP), conserving the folder structure as is within the ZIP archive.
- As it seems, the GNU C compilers only work correctly when short (8 characters) file and folder names are used. I'm not sure if UNZIP.EXE included with FreeDOS would unpack the files as it should here. Using the 8-characters-filenames unzip utility from the DISLIN website is probably the better way to do; download it and add it to the ISO with the DJGPP files.
The screenshot shows the content of my CDROM (mounted as drive letter F:).
![]() |
Create the directory where DJGPP should be installed and copy the “readme” and “copying” files to this directory. Copy the Dislin unzip utility
to your FreeDOS executable directory, renaming it (for example to unzip8.exe) in order not to overwrite the FreeDOS unzip utility.
mkdir c:\djgpp
cd c:\djgpp
f:
copy unzip.exe c:\freedos\bin\unzip8.exe
Using a text editor (on FreeDOS or on the host of your VMs), create a batch file including the commands to unzip all packages on the CDROM to
the DJGPP installation directory (you can extract the packages one by one, if you prefer). Here the content of my UNZIPALL.BAT:
c:
cd \djgpp
unzip8 f:\djdev205.zip
unzip8 f:\faq230b.zip
unzip8 f:\pakk023b.zip
unzip8 f:\rhid15ab.zip
unzip8 f:bnu2351b.zip
unzip8 f:\gcc930b.zip
unzip8 f:\gcc930d.zip
unzip8 f:\gdb801b.zip
unzip8 f:\gdb801d.zip
unzip8 f:\gpp930b.zip
unzip8 f:\mak44b.zip
unzip8 f:\objc930b.zip
unzip8 f:\csdpmi7b.zip
unzip8 f:\all422a*.zip
unzip8 f:\all422b*.zip
unzip8 f:\grx249s.zip
unzip8 f:\pdcur39a.zip
The archives on the CDROM (drive F:) are unpacked to the current directory (actually C:\DJGPP).
![]() |
You should change the settings in FDCONFIG.SYS: Setting the number of files to 40 and the fcbs to 40,0 (if the directives don't exist,
add them, otherwise change them; if there are higher values in your file, let these untouched); setting the value of the /E parameter of the SHELL directive to 2048
(normally, you'll have to replace /E:1024 by /E:2048). Here these directives in my FDCONFIG.SYS (the SHELL directive in your file may be somewhat different):
!FILES=40
!FCBS=40,0
SHELLHIGH=C:\FreeDOS\BIN\COMMAND.COM C:\FreeDOS\BIN /E:2048 /P=C:\FDAUTO.BAT
You will also have to add C:\DJGPP\BIN to the PATH, and create the new environment variable DJGPP set to
C:\DJGPP\DJGPP.ENV. If you often work with DJGPP, you can include these settings in FDAUTO.BAT. Otherwise creating a separate batch file is better practice. The
commands normally are as follows:
SET PATH=C:\DJGPP\BIN;%PATH%
SET DJGPP=C:\DJGPP\DJGPP.ENV
Testing the C compiler.
We can now perform a quick test of the DJGPP installation by trying to build a simple "Hello World" C program.
Here the sample source code:
/* Hello World */
#include <stdio.h>
int main(void) {
printf("\nH E L L O W O R L D !\n\n");
return 0;
}
The GNU C compiler is called gcc and may be invoked with just 2 parameters: 1. the name of the C source file, 2. the name of the executable
to create preceded by "-o" (without the quotes; the "o" meaning "output"). In our case (supposed that we actually are in the directory where hello.c is located and that
we want to have the executable there, too):
gcc hello.c -o hello.exe
The screenshots below show the build command (on the left) and the execution of the program (on the right).
![]() |
![]() |
Using RHIDE as DJGPP IDE.
The Delorie DJGPP packages for DOS include RHIDE, an IDE (editor plus debugger) for C. If you unzipped all packages shown in the directory listing of my CDROM containing the downloads at the beginning of the tutorial, RHIDE is installed and ready to be used. Just type "rhide" (without the quotes) to start it.
I want however describe here how, on my FreeDOS system, I take advantage of custom batch files, a different one for each programming language, to start the development related programs. This has several advantages:
- Possibility to set the path to the program(s) needed.
- Possibility to set the programming language specific environment variables.
- Possibility to load the LFN (long file names) driver if it is required.
- Possibility to set the current directory to the folder containing the source code.
- Possibility to start the IDE or editor that I use with this given programming language.
I have created a special directory (C:\FREEDOS\BATCH) where I place all my custom batch files, and normally I name them with a number sign (#) as last character,
just to be sure that I run my batch file and not possibly a compiler or other program with that name. So, I use BP#.BAT to start the Borland IDE for Turbo Pascal,
VB#.BAT to start the Microsoft Visual Basic environment, PERL#.BAT to start SET's Editor, that I use with Perl 5. And, for DJGPP development, I created DJGPP#.BAT;
here its content:
@echo off
set PATH=C:\DJGPP\BIN;%PATH0%
set DEVEL=djgpp
set DJGPP=C:\DJGPP\DJGPP.ENV
D:
cd \DEVEL\DJGPP
RHIDE.EXE
First, I add C:\DJGPP\BIN (that contains all DJGPP executables, including RHIDE.EXE) to the PATH. You may wonder what's this %PATH0% (instead
of normal %PATH%). It's a custom environment variable that I set equal to %PATH% in my FDAUTO.BAT, and that as a difference with %PATH% is never changed. This avoids
the PATH variable to become too long by adding specific directories for the execution of specific programs (and containing directories that are no longer needed).
The DEVEL environment variable takes track of the last programming environment used (you can ignore it here if you want). DJGPP is an
environment variable that (as we saw in the preceding section) has to be set with the DJGPP development software.
Then, the current directory is set to D:\DEVEL\DJGPP, the folder with my DJGPP source code. And finally, RHIDE
(the IDE) is started.
So, typing DJGPP# executes the commands above and the IDE starts up, as shown on the screenshot below.
![]() |
With the current directory having been set to D:\DEVEL\DJGPP, the RHIDE File > Open menu command directly opens the directory with the DJGPP source code, in particular with our HELLO.C sample, that we can now load into the editor.
![]() |
We can use the menu command Compile > Compile to compile the source in the active editor window, or Compile > Build All to build a file or project (creating an executable in the same directory than the source). If everything is ok, the message "no errors" will appear below "Creating hello.exe" in the Messages window.
You can run the executable from within RHIDE by choosing the menu command Run > Run (screenshot on the left). If there was no runtime error, an information box with the message "Program exit code: 0 (0x000)" pops up (screenshot on the right).
![]() |
![]() |
To view the program output, choose the menu command Window > User Screen (screenshot on the left). This opens the DOS shell with the last input and output that was made there (screenshot on the right), in our case the execution of DJGPP#.BAT, that starts RHIDE and then the output of our "Hello World!" program. To return to the editor window of the IDE, hit the ENTER key.
![]() |
![]() |
To terminate this tutorial, lets build a C++ program using RHIDE. Here is the code (yet another "Hello World" program):
#include <string>
#include <iostream>
using namespace std;
int main () {
string s1 = "Hello,";
string s2 = "World!";
cout << s1 + " " + s2 << endl;
return 0;
}
The screenshots show the build of the programs, with the "no errors" message (at the left), and the program execution, in the User Screen window (at the right).
![]() |
![]() |
If you find this text helpful, please, support me and this website by signing my guestbook.