Recent from talks
Nothing was collected or created yet.
DJGPP
View on Wikipedia
| DJGPP | |
|---|---|
The DJGPP environment, utilizing GCC | |
| Developer | DJ Delorie |
| Stable release | 2.05
/ November 3, 2015[1] |
| Repository | |
| Operating system | DOS and 32-bit Windows |
| Type | Compiler |
| License | GNU GPL |
| Website | www |
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[update], main components of DJGPP 2 include:
- GNU Compiler Collection 9.3.0 (10.2.0, 12.2.0 and 14.2.0[4] are also available, among other versions)
- Autoconf 2.5.9
- Automake 1.9.4
- Binutils 2.35.1
- GNU Bash 4.4
- GNU Bison 2.4.1, Flex 2.5.4
- GNU Emacs 29
- GNU MPC 1.1.0, MPFR 4.1.0
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]- FreeDOS
- Cygwin - a UNIX compatibility layer with many ported libraries and applications
- EMX - a POSIX implementation for DOS (and OS/2, too)
- GnuWin32
- MinGW - a port of the GNU toolchain for Windows, designed to require minimal runtime support
- Open Watcom C/C++ compiler
- Allegro
- Windows Subsystem for Linux
References
[edit]- ^ "Announce: DJGPP V2.05 Released". Newsgroup: comp.os.msdos.djgpp. 3 November 2015.
- ^ Eli Zaretskii (Jul 1999). "The DJGPP Project". Retrieved 20 Jul 2009.
- ^ "The history of djgpp".
- ^ "Mail Archives: djgpp-announce/2024/10/01/13:27:52". www.delorie.com. Retrieved 2025-04-12.
- ^ Wall, Kurt; Von Hagen, William (2004). The Definitive Guide to GCC. Apress. pp. 47–48. ISBN 9781590591093.
Another popular, though aging, GCC-based development system is DJGPP, D.J.[sic] Delorie's free 32-bit development environment for DOS systems.
- ^
"Guide: What is DJGPP?". Archived from the original on August 1, 2018. Retrieved November 22, 2015.
The target hardware platform for DJGPP programs is a PC platform ... running DOS ... or a DOS-compatible operating system DJGPP programs run under Windows' "dos prompt" boxes.
- ^
Microsoft (11 Oct 2007). "List of limitations in 64-Bit Windows". Archived from the original on 20 April 2010. Retrieved 20 Apr 2010.
16-bit MS-DOS and Microsoft Windows 3.x utilities will not start. If you attempt to start such a program, you receive a "Program.exe is not a valid Win32 application" error message.
External links
[edit]DJGPP
View on GrokipediaHistory 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 MS-DOS to enable 32-bit protected-mode development on personal computers.[2] This effort was sparked by a talk from Richard Stallman 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 MS-DOS environment.[2] 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 DOS extender to produce a functional 32-bit executable.[2] The primary motivation behind djgcc was to bring the full GNU toolchain to MS-DOS users without requiring a Unix-like operating system, thereby providing developers with powerful open-source tools in an era dominated by proprietary compilers.[2] At the time, MS-DOS offered limited development options, particularly for leveraging the capabilities of Intel 80386 and higher processors, which supported 32-bit protected mode but were constrained by the operating system's 16-bit architecture.[2] 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.[2] 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.[2] Delorie had to develop a custom DOS extender called Go32 to provide virtual memory support, as existing extenders lacked the necessary features for running the compiler effectively.[2] This involved porting elements of the BSD C library and integrating headers from G++ version 1.37 to establish a foundational standard library, all while navigating the constraints of DOS's segmented memory model.[2] 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.[2] This renaming underscored the toolchain's growing versatility, positioning it as a comprehensive development platform for DOS.[2]Key Milestones
DJGPP's early milestone came with the release of version 1.03 in 1991, which featured a stable port of the GNU Compiler Collection (GCC) and essential development tools, facilitating its widespread adoption among DOS users seeking a full-featured C/C++ environment.[2] 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 software development under DOS constraints.[2] 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.[4][5][3] Key enhancements across these releases encompassed the integration of prominent GNU utilities such as Bash for shell scripting, tar for archiving, and make for build automation, alongside a robust runtime library (libc) tailored for DOS-specific operations like file handling and memory management in protected mode.[2]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 open-source software under the GNU General Public License, allowing free use and modification while enabling commercial distribution without royalties.[6][7] The community plays a vital role in sustaining the project through collaborative efforts, including the maintenance of an extensive FAQ covering installation, usage, and troubleshooting, as well as bug reporting facilitated by a dedicated tracking system and the djgpp-workers mailing list for technical discussions.[8][9] 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.[10] 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 accessibility and redundancy.[11] 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.[12][13] 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.[7][14] This approach emphasizes legacy preservation for 32-bit DOS development on 80386+ hardware, with ongoing community activity evident in mailing list discussions as recent as 2024.[15]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.[16] 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 likegcc hello.c -o hello.exe.[16] By default, it generates executables in the Common Object File Format (COFF), optimized for the DOS-hosted protected-mode execution model.[17]
The runtime environment is anchored by DJGPP's implementation of the C standard library (libc), which provides essential functions augmented with DOS-specific extensions to interface with the underlying operating system.[18] 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 POSIX semantics; memory management routines that utilize the linear addressing model available in protected mode; and interrupt-handling mechanisms that abstract DOS interrupts through the runtime's DPMI interface for tasks like keyboard input or timer access.[19] This libc ensures portability while accommodating DOS limitations, such as the 8.3 filename convention and conventional memory constraints.
DJGPP incorporates a suite of essential utilities ported from GNU projects to form a complete development toolchain.[20] These include GNU Binutils, 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 Unix-like shell environment for scripting and command execution within DOS.[21] Together, these tools enable a seamless workflow from source editing to testing without requiring additional software.
The build process in DJGPP culminates in the creation of executable files using the COFF format, where object files (.o) are linked with libraries to produce a raw COFF image.[22] A critical element is the stub loader, a small 16-bit DOS executable prepended during linking by the DJGPP linker, which initializes the DPMI host, allocates extended memory, switches the CPU to 32-bit protected mode, and transfers control to the COFF code.[17] This mechanism allows standard DOS to load and run the otherwise incompatible 32-bit program, with the stub handling mode transitions and memory setup via DPMI services.[22]
Protected Mode Implementation
DJGPP utilizes the DOS Protected Mode Interface (DPMI), a standardized API that enables 32-bit protected-mode applications to execute atop real-mode DOS by providing services for mode switching, memory management, and interaction with DOS and BIOS calls. This interface, originally specified by Intel and Microsoft, 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 memory—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.[17][23] The memory model in DJGPP's protected mode implementation adopts a flat 32-bit addressing scheme, permitting access to up to 4 GB of virtual address space without the segmentation constraints of 16-bit DOS. This model relies on a minimal set of selectors—one for code and one for data—to map the entire 32-bit linear address space, eliminating the need for explicit segment calculations and enabling seamless pointer arithmetic across large memory regions. The DPMI host, such as CWSDPMI, manages the global descriptor table (GDT) to allocate these selectors and enforce protection boundaries, while virtual memory support allows swapping to disk if physical RAM is insufficient, though performance depends on available extended memory. This approach simplifies porting from other 32-bit environments and avoids the 1 MB conventional memory limit inherent in real-mode DOS.[24][25] Interrupt handling in DJGPP's protected mode follows DPMI protocols, where the host maintains a separate interrupt descriptor table (IDT) for 32-bit vectors, distinct from the real-mode interrupt vector table at address 0000:0000. Hardware interrupts are reflected by the DPMI server from real mode to protected mode, 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 entry point, 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 protected mode to maintain responsiveness. Memory used by handlers must be locked with functions like _go32_dpmi_lock_code() to prevent paging faults during execution.[26][17]
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 extended memory 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.[24][23]
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.[27] 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.[27] 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.[3] 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.[1] 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.[27] 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 commandgcc -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 GNU utilities that enable a Unix-like development workflow on DOS systems, including the Bash shell for scripting, grep for pattern searching, diff for file comparisons, patch for applying changes, and various file utilities such as ls, cp, and mv. These tools incorporate Unix-like syntax and command-line options, facilitating familiar operations despite the underlying DOS environment.[28][29] 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.[30] Additionally, globbing support in tools like Bash expands wildcard patterns (e.g., *.c) into full file lists, streamlining batch operations and makefile usage.[28] 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 input/output routines (e.g., printf, fopen via <stdio.h>). This libc is optimized for the 32-bit protected-mode environment and ensures portability for DOS-targeted applications.[31] 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, MIDI playback, keyboard, and mouse input, making it suitable for developing retro-style games.[32][33] Build tools in DJGPP include ports of Automake and Autoconf, 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.[34] The ported GNU Make (version 3.75 or later) further integrates with these by processing Unix-style makefiles and shells.[35] For debugging, DJGPP incorporates the GNU Debugger (GDB), which supports native debugging of 32-bit programs via DOS stubs that load the executable into protected mode; specific commands like "info dos" provide insights into DOS-specific states, such as interrupt vectors and memory selectors.[36][37]Compatibility
Operating System Environments
DJGPP provides native support for 32-bit protected-mode development on MS-DOS 5.0 and later versions, DR-DOS 6.0 and higher, Novell DOS 7, Caldera OpenDOS 7.01 and 7.02, and FreeDOS, all running on 80386 or compatible processors.[23] These environments leverage the DOS Protected Mode Interface (DPMI) specification to enable access to extended memory beyond the 640 KB conventional limit, allowing DJGPP-compiled programs to utilize up to 256 MB of address space depending on the host's capabilities.[27] FreeDOS, in particular, offers full compatibility as a modern open-source DOS clone, supporting DJGPP tools and executables without modification.[27] In emulated settings, DJGPP operates within DOS boxes provided by Windows 3.1 and 3.11, Windows 95/98/ME (using DOS 7), Windows NT (on Intel platforms), OS/2 including Warp, and Linux DOSEmu.[23] These hosts supply built-in DPMI services, enabling seamless execution of DJGPP development tools and binaries. Modern emulation further extends support through applications like DOSBox (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 Windows 11, macOS, and Linux by providing a virtual DOS environment with extended memory emulation.[27][38] Compatibility challenges arise on Windows XP and later versions due to limitations in the NT Virtual DOS Machine (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.[39] While basic DJGPP programs can execute via NTVDM on 32-bit Windows XP, 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.[40] On 64-bit Windows editions, NTVDM is unavailable, necessitating full emulation like DOSBox for any DOS-based DJGPP usage.[41] 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.[23] The distribution is typically extracted toC:\DJGPP, creating subdirectories such as bin, lib, and include; environment variables must then be configured in AUTOEXEC.BAT—PATH including C:\DJGPP\BIN, and DJGPP set to C:\DJGPP\DJGPP.ENV—to locate binaries, libraries, and configuration files.[42] A DPMI host, such as the bundled CWSDPMI extender, is required if the native environment lacks one.[23]
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.[27] The associated C library further adheres to ANSI standards, facilitating portable code development on DOS platforms.[27] Partial support for the C99 standard is available in later versions, including dedicated header files and specific functions such asrintl to align with C99 requirements; recent ports of GCC up to version 14.2.0 (as of October 2024) enhance compiler support for C11 and C17 standards, though runtime library compliance remains partial.[39][3]
The environment offers partial emulation of POSIX.1 standards, enabling Unix-like system calls through compatible headers and libraries that mimic essential behaviors.[30] 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.[43] This emulation prioritizes compatibility for porting Unix applications while adapting to DOS constraints.
Integration with the DOS API is comprehensive, allowing direct access to INT 21h interrupts for core system services such as file I/O, directory management, and program execution.[44] Functions like intdos() and int86() enable invocation of these interrupts from protected mode, supporting subfunctions including 09h (string output), 3Ch (file creation), and 40h (file writing).[44] Extensions for peripherals are provided through library wrappers: keyboard input leverages BIOS INT 16h and hardware INT 09h hooks, mouse support utilizes INT 33h via DPMI translations, and graphics operations interface with BIOS INT 10h or VGA modes, often augmented by third-party libraries for enhanced functionality.[45]
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.[30] Libraries include wrappers for file paths, converting Unix forward slashes (e.g., /dev/null) to DOS equivalents (e.g., NUL) and handling case-insensitivity.[46] Signal handling emulates POSIX semantics but is constrained to DOS events; for example, SIGINT is generated by hooking the keyboard interrupt (INT 09h) in response to the break key, while other signals like SIGABRT are raised synchronously during exceptions.[45]
Key differences from full POSIX compliance arise from DOS's single-tasking nature: true multitasking is absent, preventing concurrent process execution or inter-process communication primitives like pipes in a multi-process context.[47] Signals are limited to asynchronous events tied to DOS interrupts or synchronous errors, without support for advanced POSIX features such as real-time signals or process groups.[45] These adaptations allow DJGPP to bridge Unix portability with DOS realities, though developers must account for the emulated limitations in multi-process designs.
