Hubbry Logo
DJGPPDJGPPMain
Open search
DJGPP
Community hub
DJGPP
logo
8 pages, 0 posts
0 subscribers
Be the first to start a discussion here.
Be the first to start a discussion here.
DJGPP
DJGPP
from Wikipedia

DJGPP
DeveloperDJ Delorie
Stable release
2.05 / November 3, 2015; 9 years ago (2015-11-03)[1]
Repository
Operating systemDOS and 32-bit Windows
TypeCompiler
LicenseGNU GPL
Websitewww.delorie.com/djgpp

DJ's GNU Programming Platform (DJGPP)[2] is a software development suite for Intel 80386-level and above, IBM PC compatibles which supports DOS operating systems. It is guided by DJ Delorie, who began the project in 1989. It is a port of the GNU Compiler Collection (GCC), and mostly GNU utilities such as Bash, find, tar, ls, GAWK, sed, and ld to DOS Protected Mode Interface (DPMI). Supported languages include C, C++, Objective-C/C++, Ada, Fortran, and Pascal. It was originally called DJGCC, and was later renamed from DJGCC to DJGPP when C++ support was added, though the "PP" was said to stand for "Programming Platform" rather than "Plus Plus".[3]

Overview

[edit]

The compiler generates 32-bit code, which runs natively in 32-bit protected mode while switching back to 16-bit DOS calls for basic OS support. However, unlike the Open Watcom C/C++ compiler, it is not a zero-based flat model due to preferring NULL pointer protection for better stability. It is currently based upon a variant of the COFF format. It can access up to 4 GB of RAM in pure DOS when using a suitable DPMI host (e.g., CWSDPMI r7 or HDPMI32).

As of April 2025, main components of DJGPP 2 include:

It is also possible to use DJGPP to cross-compile software to DOS, for example on UNIX / Linux. Both the DJGPP libraries and the programs can be compiled this way, linked and then deployed to machines with DOS or DOS emulators.

Compatibility

[edit]

DJGPP presents the programmer an interface which is compatible with the ANSI C and C99 standards, DOS APIs, and an older POSIX-like environment. Compiled binaries are long filename (LFN) aware and can handle such names under most 32-bit Windows by default, but they cannot use the Win16 or Win32 APIs that graphical programs on Windows need.[5] terminate-and-stay-resident (TSR) programs to support LFNs under plain DOS or Windows NT 4 are available.

While DJGPP runs in 32-bit protected mode, its stub and library heavily rely on many 16-bit DOS and BIOS calls. Because the x86-64 versions of Windows lack support for 16-bit programs,[6][7] there is no NTVDM, and DJGPP applications cannot be run. Under x86-64 systems these applications function only through emulation (e.g. DOSBox), x86 virtualization (e.g. VirtualBox), or similar (e.g. Linux's DOSEMU). This problem arises because in long mode x86-64 processors do not support the virtual 8086 mode used to run 16-bit code in IA-32 processors. Newer x86 CPUs with VT-x do support paged real mode and unrestricted guest mode execution.

See also

[edit]

References

[edit]
[edit]
Revisions and contributorsEdit on WikipediaRead on Wikipedia
from Grokipedia
DJGPP, also known as DJ's GNU Programming Platform, is a free software development suite that provides a complete 32-bit environment for C and C++ programming on , featuring ports of the Compiler Collection (GCC) and various utilities tailored for 80386 and higher processors. It enables developers to create protected-mode applications that leverage and modern features while remaining compatible with the operating system, without requiring a full environment. The project originated in 1989 when developer DJ Delorie, inspired by a talk from Richard Stallman, began porting GCC version 1.35 to MS-DOS using tools like the Phar Lap DOS extender, initially naming it djgcc. Key milestones include the release of version 1.03 in the early 1990s with the custom Go32 extender for virtual memory support, followed by enhancements in versions 1.05 through 1.11 that added C++ capabilities, VCPI server integration, and DPMI (DOS Protected Mode Interface) compatibility via DPMIEMU. The major version 2.00 arrived on February 5, 1996, introducing a self-bootstrapping assembler (djasm) and improved portability, with subsequent updates like 2.01 (October 1996) and 2.02 (December 1998) refining stability and tool integration; development has continued with ongoing community maintenance, including support for recent GCC versions such as 14.2.0 as of 2024. DJGPP's significance lies in its role as a pioneering tool for 32-bit DOS development during the , when DOS was dominant but limited to 16-bit real-mode programming on earlier hardware. It powered notable applications, including ports of id Software's * and , demonstrating its capability for high-performance graphics and document processing on period hardware. As of 2025, the core version remains 2.05, with community ports supporting GCC up to version 14.2.0; it remains relevant for retro computing, game development, and emulation projects, often used within to recreate authentic programming workflows on modern systems.

History and Development

Origins

DJGPP originated in 1989 when DJ Delorie initiated the project under the name "djgcc," aiming to port the GNU Compiler Collection (GCC) to to enable 32-bit protected-mode development on personal computers. This effort was sparked by a talk from at a meeting of the Northern New England Unix Users Group, where Stallman expressed skepticism about the feasibility of running GCC on the 16-bit environment. Delorie's initial work involved cross-compiling GCC version 1.35 on an ISC Unix system, incorporating custom system calls and utilizing Phar Lap's to produce a functional 32-bit executable. The primary motivation behind djgcc was to bring the full to users without requiring a operating system, thereby providing developers with powerful open-source tools in an era dominated by proprietary compilers. At the time, offered limited development options, particularly for leveraging the capabilities of 80386 and higher processors, which supported 32-bit but were constrained by the operating system's 16-bit architecture. Delorie sought to address this gap by creating a development environment that could harness the 80386's advanced features, allowing programmers to build more efficient and capable applications directly on DOS platforms. Developing djgcc presented significant challenges, primarily in adapting GCC's Unix-oriented design to MS-DOS's restrictive 16-bit environment and inherent memory limitations. Delorie had to develop a custom called Go32 to provide support, as existing extenders lacked the necessary features for running the effectively. This involved porting elements of the BSD C library and integrating headers from G++ version 1.37 to establish a foundational , all while navigating the constraints of DOS's segmented memory model. In the early 1990s, as C++ support was integrated into the project, the name was changed from "djgcc" to "djgpp," standing for "DJ's GNU Programming Platform" to reflect its expanded scope beyond just the C compiler. This renaming underscored the toolchain's growing versatility, positioning it as a comprehensive development platform for DOS.

Key Milestones

DJGPP's early milestone came with the release of version 1.03 in , which featured a stable of Compiler Collection (GCC) and essential development tools, facilitating its widespread adoption among users seeking a full-featured C/C++ environment. A significant transition occurred with the launch of version 2.0 on February 5, 1996, following over two years of intensive development; this upgrade introduced POSIX-compliant libraries derived from BSD sources and complete support for C++, enabling more advanced under DOS constraints. Subsequent refinements included version 2.03, established as the official stable release in January 2000, which solidified core functionality, while version 2.05 followed as the definitive update on November 3, 2015, incorporating long-term stability enhancements; meanwhile, the GCC port within DJGPP continued evolving, reaching version 14.2.0 by October 1, 2024. Key enhancements across these releases encompassed the integration of prominent utilities such as Bash for shell scripting, for archiving, and make for , alongside a robust runtime library (libc) tailored for DOS-specific operations like file handling and in .

Community and Maintenance

DJGPP's development and upkeep have been led by DJ Delorie since its inception, with the project hosted on delorie.com and distributed as under the GNU General Public License, allowing free use and modification while enabling commercial distribution without royalties. The plays a vital role in sustaining the project through collaborative efforts, including the maintenance of an extensive covering installation, usage, and , as well as bug reporting facilitated by a dedicated and the djgpp-workers for technical discussions. Volunteers contribute significantly, with Andris Pavenis notable for porting newer versions of GCC to DJGPP, such as GCC 5.2.0, GCC 4.9.3, and GCC 4.8.5, ensuring compatibility with modern compiler advancements despite the DOS target environment. Distribution occurs primarily through the official FTP site at delorie.com, offering the complete v2.05 package and component zips, supplemented by international mirrors to improve and . For source access, a GitHub mirror of the original CVS repository provides an alternative to anonymous CVS checkouts from cvs.delorie.com, supporting developers in reviewing and building from the latest snapshots. Maintenance remains active, centered on compatibility enhancements like GCC ports and occasional library updates, though the core DJGPP v2.05 release, finalized in 2015 after a prolonged beta period for v2.04, has seen no major structural changes since then. This approach emphasizes legacy preservation for 32-bit development on 80386+ hardware, with ongoing community activity evident in discussions as recent as 2024.

Technical Architecture

Core Components

DJGPP's core revolves around a port of the GNU Compiler Collection (GCC), which serves as the central tool for compiling C and C++ source code into 32-bit protected-mode executables compatible with MS-DOS environments. This port enables developers to produce efficient, royalty-free programs targeting Intel 80386 and later processors, leveraging GCC's preprocessor (cpp), compiler proper (cc1 or cc1plus), assembler integration, and linker invocation in a single command like gcc hello.c -o hello.exe. By default, it generates executables in the Common Object File Format (COFF), optimized for the DOS-hosted protected-mode execution model. The runtime environment is anchored by DJGPP's implementation of the (libc), which provides essential functions augmented with DOS-specific extensions to interface with the underlying operating system. These extensions include low-level file I/O operations that handle DOS file systems, such as support for long filenames and device handling beyond standard semantics; routines that utilize the linear addressing model available in ; and interrupt-handling mechanisms that abstract DOS interrupts through the runtime's DPMI interface for tasks like keyboard input or timer access. This libc ensures portability while accommodating DOS limitations, such as the convention and constraints. DJGPP incorporates a suite of essential utilities ported from GNU projects to form a complete development . These include , featuring the assembler (as) for generating COFF object files from assembly code and the linker (ld) for combining objects into executables; the GNU Make utility for automating builds via Makefiles; the GNU Debugger (GDB) for runtime debugging of protected-mode programs; and a port of Bash providing a shell environment for scripting and command execution within DOS. Together, these tools enable a seamless from source editing to testing without requiring additional software. The build process in DJGPP culminates in the creation of files using the COFF format, where object files (.o) are linked with libraries to produce a raw COFF image. A critical element is the stub loader, a small 16-bit DOS prepended during linking by the DJGPP linker, which initializes the DPMI host, allocates , switches the CPU to 32-bit , and transfers control to the COFF code. This mechanism allows standard DOS to load and run the otherwise incompatible 32-bit program, with the stub handling mode transitions and setup via DPMI services.

Protected Mode Implementation

DJGPP utilizes the (DPMI), a standardized that enables 32-bit protected-mode applications to execute atop real-mode DOS by providing services for mode switching, , and interaction with DOS and calls. This interface, originally specified by and , allows DJGPP programs to operate in a protected environment while accessing DOS resources through controlled transitions between real and protected modes. To support systems lacking a native DPMI provider, DJGPP version 2.x includes CWSDPMI, a compact 32-bit DPMI host developed by Charles W. Sandmann, which automatically initializes if no other DPMI services are detected. CWSDPMI, derived from the GO32 extender code of DJGPP v1, requires minimal conventional —typically 64 KB—and handles the initial switch from real-mode DOS to protected mode by allocating necessary descriptors and setting up the execution environment for the 32-bit code. The memory model in DJGPP's protected mode implementation adopts a flat 32-bit addressing scheme, permitting access to up to 4 GB of without the segmentation constraints of 16-bit DOS. This model relies on a minimal set of selectors—one for and one for data—to map the entire 32-bit linear , eliminating the need for explicit segment calculations and enabling seamless pointer arithmetic across large memory regions. The DPMI host, such as CWSDPMI, manages the (GDT) to allocate these selectors and enforce protection boundaries, while support allows swapping to disk if physical RAM is insufficient, though performance depends on available . This approach simplifies porting from other 32-bit environments and avoids the 1 MB limit inherent in real-mode DOS. Interrupt handling in DJGPP's protected mode follows DPMI protocols, where the host maintains a separate (IDT) for 32-bit vectors, distinct from the real-mode at address 0000:0000. Hardware interrupts are reflected by the DPMI server from to , ensuring that events like timer ticks or disk I/O can trigger protected-mode handlers without full context switches for every occurrence. DJGPP employs DOS/4GW-style stubs in the executable format: a real-mode stub loads the DPMI host and transfers control to a protected-mode , while callback stubs facilitate real-mode service calls (e.g., via _dpmi_int()) and protected-mode interrupt installation (e.g., via _go32_dpmi_set_protected_mode_interrupt_vector()). Software interrupts to DOS typically require mode switching, but critical ones like INT 23h (Ctrl-C) and INT 24h (critical error) are handled natively in to maintain responsiveness. Memory used by handlers must be locked with functions like _go32_dpmi_lock_code() to prevent paging faults during execution. Compared to 16-bit DOS programming, this protected-mode setup provides significant advantages, including code and data segments exceeding the 64 KB limit, direct access to beyond DOS's 640 KB conventional boundary, and enhanced performance through reduced mode switches for memory operations and larger working sets. These features enable efficient compilation and execution of complex programs, such as those using GCC, without the fragmentation or relocation issues common in segmented real-mode environments, though they necessitate a 386-compatible CPU and a DPMI host for operation.

Features

Language and Compiler Support

DJGPP provides comprehensive support for the C and C++ programming languages through its port of the GNU Compiler Collection (GCC). The system offers full compliance with the ANSI/ISO C standard (C89), enabling developers to write portable C code that adheres to industry norms. For C++, the core DJGPP version 2 implementation supports the C++98 standard, allowing for object-oriented programming features such as classes, templates, and exception handling within the constraints of a 32-bit DOS environment. Recent updates to the GCC port, including version 14.2.0 released in 2024, introduce partial support for later standards like subsets of C++11, though full adoption is limited by the underlying runtime environment. The GCC compiler in DJGPP incorporates a range of optimization levels to balance compilation speed and code performance, from -O0 for debugging without optimizations to -O3 for aggressive optimizations that enhance execution efficiency on x86 architectures. Developers can utilize inline assembly via GCC's extended asm syntax, facilitating direct x86 instruction integration for low-level operations such as custom interrupt handling or performance-critical routines tailored to DOS. Additionally, cross-compilation flags enable targeting DOS-specific environments, ensuring generated code runs in protected mode on 80386 and higher processors. Due to the inherent limitations of the DOS operating system, such as restricted memory addressing and lack of native multithreading, DJGPP does not provide full support for advanced standards like C11 or C++17; features relying on atomic operations, threads, or extended integer types are either unavailable or require DOS-specific workarounds. However, the system includes extensions for DOS APIs, such as direct access to interrupt vectors and DPMI services, which integrate seamlessly with standard C and C++ code. For example, to generate code optimized for the 80386 processor, developers can compile a source file using the command gcc -m386 -O2 example.c -o example.exe, which specifies the target architecture and applies moderate optimizations while producing a DOS-executable binary. This approach exemplifies DJGPP's focus on efficient, standards-compliant development for legacy environments.

Tools and Libraries

DJGPP provides a suite of ported utilities that enable a development workflow on DOS systems, including the Bash shell for scripting, for pattern searching, for file comparisons, patch for applying changes, and various file utilities such as , cp, and mv. These tools incorporate syntax and command-line options, facilitating familiar operations despite the underlying DOS environment. A key feature of these utilities is support for long filenames (LFNs) through integration with DOS extenders that implement the LFN API, allowing paths exceeding the traditional 8.3 format and enabling more flexible file handling in development projects. Additionally, globbing support in tools like Bash expands wildcard patterns (e.g., *.c) into full file lists, streamlining batch operations and makefile usage. The ecosystem includes a comprehensive C library (libc) that implements standard ISO C functions, covering mathematical operations (e.g., sin, cos via <math.h>), string manipulation (e.g., strlen, strcpy via <string.h>), and routines (e.g., , fopen via <stdio.h>). This libc is optimized for the 32-bit protected-mode environment and ensures portability for DOS-targeted applications. Beyond the core libc, DJGPP supports additional libraries such as Allegro, a cross-platform game programming library ported for DOS, which handles VGA/SVGA graphics, digital audio, playback, keyboard, and mouse input, making it suitable for developing retro-style games. Build tools in DJGPP include ports of and , adapted to handle DOS limitations while supporting the generation of portable makefiles and configuration scripts; these enable automated compilation processes with features like long command-line support for complex builds. The ported GNU Make (version 3.75 or later) further integrates with these by processing Unix-style makefiles and shells. For debugging, DJGPP incorporates the GNU Debugger (GDB), which supports native debugging of 32-bit programs via DOS stubs that load the executable into ; specific commands like "info dos" provide insights into DOS-specific states, such as interrupt vectors and memory selectors.

Compatibility

Operating System Environments

DJGPP provides native support for 32-bit protected-mode development on 5.0 and later versions, 6.0 and higher, DOS 7, OpenDOS 7.01 and 7.02, and , all running on 80386 or compatible processors. These environments leverage the (DPMI) specification to enable access to beyond the 640 KB conventional limit, allowing DJGPP-compiled programs to utilize up to 256 MB of depending on the host's capabilities. , in particular, offers full compatibility as a modern open-source DOS clone, supporting DJGPP tools and executables without modification. In emulated settings, DJGPP operates within DOS boxes provided by and 3.11, /98/ME (using DOS 7), (on platforms), including Warp, and DOSEmu. These hosts supply built-in DPMI services, enabling seamless execution of DJGPP development tools and binaries. Modern emulation further extends support through applications like (and forks such as DOSBox-X and DOSBox Staging), which accurately simulate DPMI and allow DJGPP to run, as of 2025, on contemporary operating systems such as , macOS, and by providing a virtual DOS environment with emulation. Compatibility challenges arise on and later versions due to limitations in the NT (NTVDM) subsystem, which handles 16-bit DOS applications but imposes restrictions on DPMI services, such as reduced memory allocation reliability and instability during intensive operations. While basic DJGPP programs can execute via NTVDM on 32-bit , issues like buggy long filename handling in file I/O operations and weaker overall DPMI support compared to earlier Windows versions often lead to crashes or incomplete functionality. On 64-bit Windows editions, NTVDM is unavailable, necessitating full emulation like for any DOS-based DJGPP usage. To set up DJGPP, a minimum of 4 MB of extended RAM is recommended (with 64 KB free conventional memory sufficient for the extender), alongside 15–35 MB of free disk space for installation and temporary files. The distribution is typically extracted to C:\DJGPP, creating subdirectories such as bin, lib, and include; environment variables must then be configured in AUTOEXEC.BATPATH including C:\DJGPP\BIN, and DJGPP set to C:\DJGPP\DJGPP.ENV—to locate binaries, libraries, and configuration files. A DPMI host, such as the bundled CWSDPMI extender, is required if the native environment lacks one.

Standards and APIs

DJGPP provides strong compliance with the ANSI/ISO C standard through its port of the GNU Compiler Collection (GCC), ensuring that core language features are fully supported in both compilation and runtime behaviors. The associated C library further adheres to ANSI standards, facilitating portable code development on DOS platforms. Partial support for the standard is available in later versions, including dedicated header files and specific functions such as rintl to align with C99 requirements; recent ports of GCC up to version 14.2.0 (as of October 2024) enhance compiler support for and C17 standards, though compliance remains partial. The environment offers partial emulation of POSIX.1 standards, enabling Unix-like system calls through compatible headers and libraries that mimic essential behaviors. For instance, process creation via fork() is not natively supported due to DOS limitations and always returns -1 with errno set to ENOMEM; instead, POSIX-style spawning is achieved using functions like spawn() or spawnv(), which execute new programs without duplicating the parent process. This emulation prioritizes compatibility for porting Unix applications while adapting to DOS constraints. Integration with the is comprehensive, allowing direct access to INT 21h interrupts for core system services such as file I/O, directory management, and program execution. Functions like intdos() and int86() enable invocation of these interrupts from , supporting subfunctions including 09h (string output), 3Ch (file creation), and 40h (file writing). Extensions for peripherals are provided through wrappers: keyboard input leverages BIOS and hardware INT 09h hooks, mouse support utilizes INT 33h via DPMI translations, and graphics operations interface with BIOS or VGA modes, often augmented by third-party libraries for enhanced functionality. DJGPP's headers draw from a blend of BSD and System V Unix traditions, ensuring broad compatibility with Unix-style interfaces while incorporating DOS-specific modifications. Libraries include wrappers for file paths, converting Unix forward slashes (e.g., /dev/null) to DOS equivalents (e.g., NUL) and handling case-insensitivity. Signal handling emulates semantics but is constrained to DOS events; for example, SIGINT is generated by hooking the keyboard interrupt (INT 09h) in response to the , while other signals like SIGABRT are raised synchronously during exceptions. Key differences from full POSIX compliance arise from DOS's single-tasking nature: true multitasking is absent, preventing concurrent process execution or primitives like in a multi-process context. Signals are limited to asynchronous events tied to DOS interrupts or synchronous errors, without support for advanced features such as real-time signals or process groups. These adaptations allow DJGPP to bridge Unix portability with DOS realities, though developers must account for the emulated limitations in multi-process designs.

Applications and Legacy

Notable Uses

DJGPP played a pivotal role in game development during the , most notably as the chosen by for the DOS port of Quake released in 1996, where it facilitated the use of inline assembly to optimize on 32-bit protected-mode environments. In the realm of operating system development, DJGPP supported early hobbyist projects focused on x86 architectures, including prototypes for —whose C library was directly based on DJGPP's libc—and various tools for creation, enabling developers to build and test low-level components in a DOS-based . DJGPP also powered key utility ports to DOS, such as the Web2C distribution of and adapted for , which allowed document processing on older hardware, alongside the DJGPP port of that provided a full-featured for DOS and Windows environments. Furthermore, it underpinned numerous tools distributed in the 1990s, including compression utilities like Info-ZIP and networking libraries such as WatTCP, which were compiled and run under its ecosystem. Overall, DJGPP's ability to compile 32-bit applications for DOS extended the platform's viability into the mid-1990s, bridging the gap before Windows NT's widespread adoption, and it gained traction in the for creating compact, high-performance demos as well as among independent developers experimenting with advanced graphics and real-time software.

Current Status

DJGPP remains actively maintained in a limited capacity, with its core framework stable at version 2.05 since its official release, while ports of the Compiler Collection (GCC) have been updated to version 14.2.0 in October 2024 to ensure compatibility with contemporary development tools. This maintenance focuses on preserving functionality for retro computing applications, where DJGPP enables 32-bit C/C++ programming on legacy systems without significant alterations to its foundational protected-mode implementation. In modern contexts, DJGPP integrates seamlessly with emulation tools like , facilitating game development and educational projects by allowing developers to compile and test DOS applications on contemporary hardware. For instance, extensions such as "dos-dev" streamline workflows for DOS C++ development, incorporating DJGPP cross-compilation, remote debugging via GDB, and execution to support 32-bit protected-mode applications. Preservation efforts ensure DJGPP's availability through official archives hosted on delorie.com, which include documentation, binaries, and CVS repositories, alongside mirrors that replicate the original for broader accessibility and community contributions. Active mailing lists, such as djgpp-announce and djgpp-workers, continue to handle updates and discussions, reflecting ongoing interest in sustaining the . Looking ahead, DJGPP occupies a niche role in maintaining legacy codebases and supporting embedded systems reliant on DOS environments, particularly in retro gaming and historical software preservation, though it has been largely superseded by advanced cross-compilers for similar targets in professional development.

References

Add your contribution
Related Hubs
User Avatar
No comments yet.