C语言 MS-DOS 的 C 编译器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15096609/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
C compiler for MS-DOS
提问by Tarek
I have installed MS-DOS 6.22 on a VirtualBox virtual machine, everything is working well, the purpose of doing that is to compile a program written in the C language that displays and edits bits in the (virtual) RAM. However, I need a way to install a C compiler on the virtual MS-DOS operating system.
我在 VirtualBox 虚拟机上安装了 MS-DOS 6.22,一切正常,这样做的目的是编译一个用 C 语言编写的程序,该程序在(虚拟)RAM 中显示和编辑位。但是,我需要一种在虚拟 MS-DOS 操作系统上安装 C 编译器的方法。
采纳答案by Tarek
I have installed the compiler and it worked successfully, if you want the ova here is the link MS-DOS ova with C compiler
我已经安装了编译器并且它运行成功,如果你想要 ova,这里是MS-DOS ova 与 C 编译器的链接
To open the compiler:
打开编译器:
cd TC
TC
and that's it! You can write C and compile. The best part is that you can deal with registers and memory without any restriction.
就是这样!您可以编写C并编译。最好的部分是您可以不受任何限制地处理寄存器和内存。
回答by ssokolow
Here are a bunch of details others have missed:
以下是其他人遗漏的一些细节:
Nobody mentioned DJGPPat all.
It's a protected-mode DOS port of GCC and probably has the largest selection of libraries and guides available of any of the open-source options. (Including a Turbo Vision portwith an installation HOWTO)
No matter what you're trying to do, OpenWatcom(source) is likely to meet your needs.
OpenWatcom still includes the free license to use DOS/4GW that made it so popular back in the day. (When you see a game like DOOM saying "DOS/4GW Protected Mode Runtime" when it starts, that means that it was built using Watcom C/C++, because DOS/4GW is the special Watcom bundle version of DOS/4G.)
In fact, DOS/4GW's creator was trying to dig up the source code for a newer version of DOS/4GW to contribute to Open Watcom when he passed away.
If you don't want nostalgia, OpenWatcom bundles newer, better alternatives to DOS/4GW, like DOS/32 and PMODE/W.
If you want to putter around with Windows 3.1 programming, OpenWatcom includes Win386, a 32-bit extender for Window 3.x which was used by companies like Sierra for their Windows 3.1 games before Microsoft produced their own "Win32s" 32-bit API addon.
OpenWatcom can target all supported platforms from a single install. (I use it to build various DOS and Windows test EXEs from Linux.)
OpenWatcom can target a lotof retro-platforms:
- COM files
- real-mode EXEs (there's a separate set of options to select minimum CPU requirement)
- protected-mode EXEs (with your choice of several extenders)
- Windows 3.1 EXEs (with or without the Win386 extender)
- Lots of other formats you probably don't care about
If your project must run in real mode (ie. no DJGPP) and you want something with a more modern optimizer than the one in Open Watcom C/C++, there's a fork of GCC named GCC IA16that you can try. (Though I don't know how complete its support is for the various memory models and calling conventions used in the 16-bit x86 ecosystem.)
If you want something that'll let you run the IDE and compiler on ancient hardware, the Pacific Ccompiler and IDE list a 286 CPU as their minimum requirement but can also be run in DOSEMUfor easy integration into Linux-based build automation.
Here are a few other free C compilers for DOS, though they lack the huge ecosystems DJGPP and OpenWatcom have:
根本没有人提到DJGPP。
它是 GCC 的保护模式 DOS 端口,并且可能拥有所有开源选项中最多的可用库和指南。(包括带有安装 HOWTO的Turbo Vision 端口)
无论您尝试做什么,OpenWatcom(源代码)都可能满足您的需求。
OpenWatcom 仍然包含使用 DOS/4GW 的免费许可证,这使得它在当时非常流行。(当你看到像 DOOM 这样的游戏在启动时说“DOS/4GW Protected Mode Runtime”,这意味着它是使用 Watcom C/C++ 构建的,因为 DOS/4GW 是 DOS/4G 的特殊 Watcom 捆绑版本。)
事实上,DOS/4GW 的创建者在他去世时正试图挖掘新版本 DOS/4GW 的源代码,以便为 Open Watcom 做出贡献。
如果您不想怀旧,OpenWatcom 捆绑了更新、更好的 DOS/4GW 替代品,如 DOS/32 和 PMODE/W。
如果您想玩转 Windows 3.1 编程,OpenWatcom 包括 Win386,这是一个 Window 3.x 的 32 位扩展程序,在 Microsoft 生产自己的“Win32s”32 位 API 插件之前,Sierra 等公司将其用于 Windows 3.1 游戏.
OpenWatcom 可以通过一次安装针对所有支持的平台。(我用它从 Linux 构建各种 DOS 和 Windows 测试 EXE。)
OpenWatcom 可以针对许多复古平台:
- COM文件
- 实模式 EXE(有一组单独的选项来选择最低 CPU 要求)
- 保护模式 EXE(可选择多个扩展程序)
- Windows 3.1 EXE(带或不带 Win386 扩展程序)
- 您可能不关心的许多其他格式
如果您的项目必须在实模式下运行(即没有 DJGPP),并且您想要一些比 Open Watcom C/C++ 中的优化器更现代的优化器,那么您可以尝试一个名为GCC IA16的 GCC 分支。(虽然我不知道它对 16 位 x86 生态系统中使用的各种内存模型和调用约定的支持有多完整。)
如果您想要让您在古老的硬件上运行 IDE 和编译器的东西,Pacific C编译器和 IDE 将 286 CPU 列为他们的最低要求,但也可以在DOSEMU 中运行,以便轻松集成到基于 Linux 的构建自动化中。
以下是其他一些用于 DOS 的免费 C 编译器,尽管它们缺乏 DJGPP 和 OpenWatcom 拥有的庞大生态系统:
You may also want to run the UPXcompressor on the EXE files you build so you'll have more free space on any floppy images you make. (Don't forget to run it with --8086if you're targeting something older than a 386.)
您可能还想在您构建的 EXE 文件上运行UPX压缩器,以便您在制作的任何软盘映像上都有更多的可用空间。(--8086如果你的目标是比 386 更旧的东西,请不要忘记运行它。)
It's capableof compressing EXE, COM, and SYS files and using this sort of executable compression was commonplace back in the day.
它能够压缩 EXE、COM 和 SYS 文件,并且使用这种可执行压缩在当时是司空见惯的。
(However, two of the three major formats UPX doesn't compress are OS/2 and Windows 3.1 executables. I'm still looking into the best option for those, given that LxLitedoesn't get along with OpenWatcom-generated EXEs.)
(不过,UPX 不压缩的三种主要格式中有两种是 OS/2 和 Windows 3.1 可执行文件。鉴于LxLite与 OpenWatcom 生成的 EXE 不兼容,我仍在寻找最佳选择。)
回答by speeder
The Turbo C compiler for DOS is just awesome, and freeware.
用于 DOS 的 Turbo C 编译器非常棒,而且是免费软件。
Official site link http://edn.embarcadero.com//article/20841
官网链接 http://edn.embarcadero.com//article/20841
Also there are Microsoft QuickC but I don't know how hard is to find it.
还有Microsoft QuickC,但我不知道找到它有多难。
Or Watcom C, but I don't know if their OpenWatcom version works with DOS
或 Watcom C,但我不知道他们的 OpenWatcom 版本是否适用于 DOS
回答by Mahmut Ali ?ZKURAN
You may want to try Open Watcomor Borland Turbo Series. There are other options but best are those 2 imho.
您可能想尝试Open Watcom或Borland Turbo 系列。还有其他选择,但最好的是那些 2 imho。
回答by Mahmut Ali ?ZKURAN
The Borland C++ 4.53 is the most capable, as it can output DOS (in all memory models) and Windows 3.1 and 95 executables, from several IDEs, either a DOS or Windows one. It includes command line tools, but again, it has to be hosted on a PC platform or something like DOSBox.
Borland C++ 4.53 是最强大的,因为它可以从多个 IDE(DOS 或 Windows IDE)输出 DOS(在所有内存模型中)和 Windows 3.1 和 95 可执行文件。它包括命令行工具,但同样,它必须托管在 PC 平台或类似 DOSBox 的平台上。
This original package for Borland C 4 was fairly hefty, but not nearly as insane as the literal bookshelf which came with Borland C++ 3.1. Borland C++ 3.1 is more than likely the heaviest andlargest retail commercial software product box in history.
Borland C 4 的原始包相当庞大,但不像 Borland C++ 3.1 附带的文字书架那么疯狂。Borland C++ 3.1 很可能是历史上最重、最大的零售商业软件产品盒。
回答by Alos
Open Watcom has a C compiler that will work on DOS: Open Watcom
Open Watcom 有一个可以在 DOS 上运行的 C 编译器:Open Watcom
You can save it and then create a virtual floppy with it: virtual floppy how to
您可以保存它,然后用它创建一个虚拟软盘:虚拟软盘如何
This should let you install it on your virtual machine.
这应该可以让您在虚拟机上安装它。
回答by Jeremy J Starcher
There are a number of compilers here:
这里有许多编译器:
http://www.compilers.net/dir/free/compilers/ccpp.htm
http://www.compilers.net/dir/free/compilers/ccpp.htm
Very specifically, I have used the "Pacific C" for several different fun projects and I was pleased with both the ease of use and overall compatibility.
非常特别的是,我已经将“Pacific C”用于几个不同的有趣项目,我对它的易用性和整体兼容性感到满意。
I was able to chase down a new URL for the download:
我能够找到一个新的下载 URL:
http://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/devel/c/pacific/
http://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/devel/c/pacific/
回答by vonbrand
回答by cesarse
Embarcadero Technologies has released Borland C++ compiler as freeware some time ago. Sadly there's no IDE, only command line tools.
Embarcadero Technologies 不久前发布了 Borland C++ 编译器作为免费软件。遗憾的是没有 IDE,只有命令行工具。

