本文介绍了在Mac OS上使用GCC编译MS-DOS的C程序(DOSBox)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Mac OS X上的Snow Leopard下运行GCC 4.2.1.我想用它来编译我15年前写的一些旧的C/C ++ DOS游戏,以便可以在.为此,它们显然需要以DOS可执行格式进行编译,有人可以告诉我如何使用GCC进行此操作吗?

I am running GCC 4.2.1 under Snow Leopard on Mac OS X. I want to use it to compile some old C/C++ DOS games I wrote 15 years ago so that I can run them under DosBox. To do this they obviously need to be compiled in DOS executable format, can anyone tell me how to do this using GCC please?

谢谢!

推荐答案

DOSBox在模拟下运行16位x86实模式代码. OSX 10.6上的常规GCC编译器以OSX操作系统和32位x86保护模式为目标,因此您不能使用它来构建在DOSBox中运行的代码.

DOSBox runs 16 bit x86 real-mode code under emulation. The regular GCC compiler on OSX 10.6 targets the OSX operating system and 32 bit x86 protected mode, so you cannot use that to build code to run in DOSBox.

您可能能够做的是在DOSBox本身中运行DOS编译器. DJGPP 是GCC的MS-DOS端口,但是它生成针对DPMI子系统的32位保护模式代码. .对我来说,尚不清楚DOSBox是否支持DPMI,但我想它确实支持DPMI,DJGPP本身位于 DOSBox中兼容性列表,因此人们可以想象一下,如果它对模拟硬件没有做任何异常的事情,它生成的代码也可能会运行.

What you may be able to do is run a DOS compiler in DOSBox itself. DJGPP is an MS-DOS port of GCC, however it generates 32bit protected mode code targetted at the DPMI subsystem. It is not clear to me that DOSBox supports DPMI, but I imagine that it does, and DJGPP itself is in the DOSBox compatability list, so one would imagine that the code it generates might run also if it does not do anything too out of the ordinary to the emulated hardware.

Borland Turbo C 也在兼容性列表中,并且.其他版本也可以下载,但是我怀疑这种分发的合法性.

Borland Turbo C is also on the compatability list, and TC 2.01 is legitimately available for free. Other versions are offered for download elsewhare, but I doubt the legality of such distribution.

但是,更强大的解决方案可能是使用 VirtualBox .如果没有MS-DOS副本,则可以尝试 FreeDOS .

A more robust solution however is probably to install a genuine MS-DOS or DOS compatible OS in a Virtual Machine hosted on OSX using VirtualBox. If you do not have a copy of MS-DOS, you might try FreeDOS.

这篇关于在Mac OS上使用GCC编译MS-DOS的C程序(DOSBox)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 01:42