4

I've been looking all over google for this but never got a clear answer.. I'm trying to write a simple hello world application and make it run under msdos (which I will be installing on a old rig lying around here).

But first things first, I've been trying to compile a normal console application and drop it in dosbox to test it out which doesn't work, just says it's invalid. So I assume I need something else to compile it with. Does this mean I'm obligated to build my code in a msdos environment? Even if this is the case, I have no clue at all how to do this, kinda a msdos dummy..

If anyone can shed some light on my case I would be very grateful!

P.S: I'm running a 64bit system

Jens Ackou
  • 151
  • 11

5 Answers5

4

You can use the free DJGPP compiler for DOS.
And here is the documentation for using DJGPP.

Chimera
  • 5,884
  • 7
  • 49
  • 81
3

I'm assuming that you mean actual DOS and not a command prompt running in Windows.

DOS is a 16-bit OS, so you will need a compiler capable of generating a 16-bit binary. A Windows console application is 32-bit, so it won't run under DOS. You don't have to build your code in a DOS environment, you will just need the right compiler.

As for compilers, you might want to check out OpenWatcom.

bta
  • 43,959
  • 6
  • 69
  • 99
  • Alright I'll try compiling the code with microsoft c++ 6.0 like Felice suggested. Good to know that I'm not wasting time trying to compile on a windows 7 machine – Jens Ackou Oct 09 '12 at 18:49
  • alright this looks like a step forward. I created a new project and made a simple hello world cpp file but when I'm trying to build by hitting f4 it slams me in the face with the error "Error(E14): Cannot execute(wpp): No such file or directory" – Jens Ackou Oct 09 '12 at 20:26
  • 1
    @JensAckou- OpenWatcom is a command-line compiler, so the F4 key must be something related to your IDE. Make sure that the OpenWatcom tools are accessible through your system's PATH (you should be able to drop into a command shell and run 'wpp' without errors). You may find it easier to build your project from the command line (using a makefile or script) instead of building through the IDE. – bta Oct 09 '12 at 20:56
  • I noticed "C:\WATCOM\BINNT;C:\WATCOM\BINW" being present related to WATCOM is present so that couldn't be a problem I think. But how would you compile a 16bit dos file in a command line? Could you give a rough example in which format I should enter this? Thanks in advance – Jens Ackou Oct 09 '12 at 21:18
  • @JensAckou- The OpenWatcom wiki has many tutorials, including [one on how to build a program using a makefile](http://www.openwatcom.org/index.php/Wmake_tutorial). If you have any questions about using OpenWatcom, I suggest consulting the wiki first. It will be your best source of information. – bta Oct 11 '12 at 00:47
  • See also the [OpenWatcom getting started guide](http://www.openwatcom.org/ftp/manuals/current/c_readme.pdf). In particular, you may find chapter 3 helpful. – bta Oct 11 '12 at 00:53
2

Microsoft Visual C++ 1.52 is the only available version of a Microsoft C++ compiler that supports compiling 16-bit code.

http://social.msdn.microsoft.com/forums/en-US/Vsexpressvc/thread/cfc848e8-a797-42a5-8537-892cfc234123

You need to find an old compiler that will generate 16bit COM files.

Louis Ricci
  • 20,804
  • 5
  • 48
  • 62
1

Could running it on a 64bit system be an issue?..

Yes, 64-bit Windows cannot execute a 16-bit program. If you install a virtual PC with MS-DOS or a 32-bit Windows system, the virtual PC will be able to execute a 16-bit program.

Do you need to edit your question to say that you're using 64-bit Windows?

Windows programmer
  • 7,871
  • 1
  • 22
  • 23
0

It sounds like you are compiling a console app on a modern version of Windows and trying to simply copy it to an old DOS box. The problem is that DOS is not forwards compatible. You cannot run a program compiled with Windows 7 on pre-Windows versions of DOS. The simplest solution is to compile your programs on the DOS box itself. Alternatively, if you want to develop on a newer machine, you need to get a cross-compiler which targets the OS where you want to run your program.

Code-Apprentice
  • 81,660
  • 23
  • 145
  • 268