DJGPP on DOSBOX…

Well I was originally looking around at the new & exciting 16bit support for HX, but so far I’m having little luck… It seems all the ‘cool’ OS/2 stuff it should do just crashes out on me…

I’m hoping to get something going eventually.

In the meantime, I had to check to see if an old MS-DOS favorite, DJGPP was still around.. And not only is it still there, but they now support GCC 4.42!

DJGPP, is simply put a port of GCC to MS-DOS. The best part, is that the compiler, libraries, and even the dos extender are all FREE. The sad thing is that DJGPP hit popularity around the mid 90’s with the rise of Windows 95, and the internet… Kind of killing 32bit MS-DOS applications… However Quake 1 shipped as a djgpp/cwsdpmi application… I’m sure there are others.

So at any rate, I was intrigued that it was still around, so I fired up DOSBox, then downloaded the zips according to the zip picker, read the readme, setup the environment, and I was off and away compiling my trivial hello world.

Sadly for me, I couldn’t sleep, so I then just grabbed the f2c/dungeon stuff and did a compile… I only had to tweak a few things, mostly a garbled long file name thing, but in no time… It was running.

 

I did manage to crash dosbox building the libf2c, but luckily changing gcc to use the -O0 (no optimizations) it was able to build the library… It’s kind of sad generating a 150kb ‘hello world’ type application, but thats the price for essentially statically linking everything….

MS-DOS isn’t the most modern thing out there…. I always wonder if those kids writing a 32bit ms-dos like os ever got anywhere…

This entry was posted in djgpp, DOSBox, gcc, Zork by neozeed. Bookmark the permalink.
avatar

About neozeed

What is there to tell? I’ve loved UNIX like things since I was first exposed to QNX in highschool (we had the Unisys ICONS!), and spent the better time of my teenage years trying to get my own UNIX… I should have bought Coherent in retrospect.. Anyways latched onto Linux in 1992, and then got some old BSD admin books and have been hooked on the VAX BSD & other big/ancient things since…!

12 thoughts on “DJGPP on DOSBOX…

  1. Hey, I've been trying to run DJGPP on DOSBox myself. Sadly all my efforts have yeilded nothing so far. The linker bugs out on me. You wouldn't care to divulge some details about setting it up to run under DosBox?

    Thanks!

  2. The only thing I changed was to increase the DPMI memory to 64 megabytes….

    I also substituted the SDL.dll with one I built myself under MinGW, that seems to handle the keyboard just fine (the one that it comes with jumbles up all kinds of weird stuff)… I didn't do anything to tweak the SDL…

    Let me know what your platform is (windows linux etc) mappings and gcc -v output..

    try a simple void main(){} style program with gcc -v

  3. DOSBox is the worst choice for compiling with DJGPP. It's not even barely as fast as a 486 (at best! very very very slow!), only geared towards games, and thus it has some bugs preventing "real world" use. (E.g. Last I tried, DOSBox doesn't truncate LFNs correctly to 8.3 when DJGPP looks for files, and that indeed will crash DOSBox.)

    If you are running this because your host OS is 64-bit (*shakes fist at no V86 mode*), you'd do *much* much better with VirtualBox or DOSEMU (although sharing files under the former is hard).

    Drop by http://www.bttr-software.de/forum if you have HX questions (or just general DOS queries). A fair few of us luddites frequent there.

  4. BTW, you don't have to use f2c, try /v2gnu/gfor442b.zip . And if static linking bothers you (although it shouldn't), use UPX (–best –lzma –all-filters), tweak your libc, use -Os, or try the DJELF hack/port (although UPX doesn't support it). I'm sure DXE/DXE3 works too, but it's probably a pain.

    P.S. Yes, FreeDOS-32 exists, stalled for a few years due to license and developer issues. It recently announced work resuming again, so hopes are good. (Or check out RDOS, which now has official OpenWatcom 1.9 support.)

    DJGPP and FreeDOS aren't dead, but NTVDM bugs, worse Windows limitations (Vista, 7) and AMD64 incompatibilities (no V86 mode!) don't help. :-/

  5. Well the big plus DJGPP has is that it'll run on the native filesystem, so I don't have to use DOS edit to edit files… 🙂

    Also the f2c thing is part of a long running thing I've been doing on using that on various platforms to see how 'portable' the resulting code is…

    What binaries I've collected are here:

    http://vpsland.superglobalmegacorp.com/install/f2c/

    Also what is the legal issues?

  6. Hello again,

    Thanks for the help.

    LFN=NO in autoexec section of dosbox.conf did the trick.

    I then renamed the .info files from libc~1.inf (real name libc.info) to libc.inf to get online help in rhide.

    Thanks again.

  7. I wanted to let others know that DOSBox 0.74 with GCC 4.61 does not work, and when compiling the simplest hello world will result in an “Invalid Opcode” SIGILL. I tried many settings, twiddling memory, etc until I simply grabbed the 4.42 version you mentioned above and it worked! Thanks!

    • Hmm Invalid Opcode almost screams that it’s been built to target a higher CPU than what DOSBox emulates… which shouldn’t be that much of a surprise as DOSBox’s primary market is vintage games of the 8086/80286/80386/80486 era…

      It may be a matter of rebuilding GCC to target a lower CPU level … or GCC 4.6 has moved beyond 80486/Pentium 1 instructions………

    • Thanks a bunch for putting this information out there, Jack. I tried to get DJGPP working in DOSBox a few weeks ago, and ran up against the same problem. I wasn’t able to find any relevant help on Google. I even visited this very page, before you commented, but it never occured to me to try another version of GCC.

      Today I decide to tackle the problem again, and Google brings me back here to find a new comment – I followed your advice (with GCC 4.44) and it worked! So again, thanks!

  8. I haven’t tried this yet, but back in the day (’90s) I created my first Deluxe Pacman game (http://home.cogeco.ca/~nroy15/games_index.html scroll down and look for v1.02 for DOS if you’re curious) I used DJGPP + Allegro which is really easy to compile under DOS with no dependencies I don’t think. I used to target 386 machines back then and it still runs under DOSBOX to this day. It was optimized at that time with -O2. I will probably set this up and try my hand at recompiling the same project using DOSBOX just for fun. I really don’t see a need to go for the newest GCC out there, not when compiling for DOS. Give Allegro 4 a try anyhow, you can still grab the source for Allegro 4.2 (don’t do a newer version unless you enjoy headaches) and it’s very simple to compile the lib and it has everything you need, sound, input, graphics etc.. ALL my Deluxe Pacman games (1 and now 2) were made with it.

    • for the quake2 port to MS-DOS I just used a cross compiler from OS X to DJGPP, and Win32 to DJGPP. It’s so much faster to run the compiler from an OS that can handle “large” files, or the dozens of includes.

      Have you thought about a SDL/modern port?

Leave a Reply

Your email address will not be published.

Notify me of followup comments via e-mail. You can also subscribe without commenting.