How to write a C ++ console console that I can run on msdos?

I searched all over Google for this, but did not get a clear answer. I am trying to write a simple welcome application of the world and make it work under msdos (which I will install on the old installation lying here).

But firstly, I tried to compile a regular console application and drop it in dosbox to check that it doesnโ€™t work, it just says that it is invalid. Therefore, I assume that I need something else to compile it. Does this mean that I am obligated to build my code in the msdos environment? Even so, I donโ€™t even know how to do this, sort of like a dummy msdos.

If someone can shed light on my cause, I would be very grateful!

PS: I am running a 64-bit system

+4
source share
5 answers

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

+4
source

I assume that you mean the actual DOS, not the command line running on Windows.

DOS is a 16-bit OS, so you will need a compiler capable of generating a 16-bit binary. The Windows console application is 32-bit, so it will not work under DOS. You do not need to create your code in a DOS environment, you just need the right compiler.

As for compilers, you can check OpenWatcom .

+2
source

Microsoft Visual C ++ 1.52 is the only available version of Microsoft C ++ that supports compilation of 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 16-bit COM files.

+2
source

Is it possible to run it on a 64-bit system? ..

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

Do you need to change your question to say that you are using 64-bit Windows?

+1
source

It looks like you are compiling a console application on a modern version of Windows and trying to just copy it to the old DOS block. The problem is that DOS is not compatible with the former. You cannot run a program compiled on Windows 7 in DOS versions prior to Windows. The easiest solution is to compile your programs directly in the DOS field. Alternatively, if you want to develop on a newer machine, you need to get a cross-compiler that focuses on the OS where you want to run your program.

0
source

Source: https://habr.com/ru/post/1438729/


All Articles