The Ubuntu Labrador

Using DOSBOX to run Turbo C++ in Ubuntu Linux

Posted by: Anurag Panda on: July 5, 2007

In many of the schools all over the world and especially in India, most of the beginner courses on C++ are based on Turbo C++. For those who do not know Turbo C++ was a protected mode compiler for MS/PC DOS systems.

Thus, when I switched to Ubuntu, what I needed to run Turbo C++. But sadly Turbo C++ cannot be natively run under Linux. I did a quick Google on Turbo C++ and found nothing worthwhile. Then in synaptic while searching for dos, I came across dosemu and I installed it. However it was very hard to configure and I never managed to run Turbo C++ properly.

Then I came across a site which mentioned DOSBOX, so I decided to give it another go for running Turbo C++. And in the end I successfully managed to run Turbo C++ almost perfectly albeit a three second delay while compiling or linking which I found much worthwhile than to rebooting to Windows.

This is how I ran Turbo C++ in Ubuntu:

INSTALLATION

The installation was easy as much as any other application in Ubuntu repository.

Simply, Go to the terminal:
sudo aptitude install dosbox

APT will now download and install DOSBOX.

CONFIGURATION

I made a directory inside my home of ‘programs’ and inside ‘programs’, I created another directory ‘dos’. This ‘dos’ folder would be the root C: of the emulated dos and hence is essential. I also created a ‘bin’ directory inside the ‘dos’ directory.

Then I copied the TC folder from my Windows partition to the ‘dos’ directory. You can also copy the installation files of Turbo C++ in the ‘dos’ directory in case you have the installation files.

Now I created the DOSBOX configuration file. First I ran went to terminal and ran DOSBOX:
dosbox

Using this command I generated the DOSBOX configuration file which will be stored as /home/user/dosbox.conf. Under the DOSBOX command prompt I executed:
config -writeconf /home/yourname/dosbox.conf

I then closed DOSBOX and now double clicked the dosbox.conf file in the root of my home folder and I configured DOSBOX to mount its C: to my /home/anurag/programs/dos. I added the following lines at the end of the configuration file below the [autoexec]:
mount c /home/username/programs/dos
C:
CD BIN

This enabled the DOSBOX to use my /home/username/programs/dos as
its C: at startup. You add as many DOS command here. All commands here are treated as DOS command and are same as commands in autoexec.bat in DOS/Windows.

Another setting I changed in DOSBOX was that I set the value of the key fullscreen to be true. You can locate this key at the top of the dosbox.conf as:

[sdl]
# fullscreen -- Start dosbox directly in fullscreen.
# fulldouble -- Use double buffering in fullscreen.
# fullresolution -- What resolution to use for fullscreen: original or fixed size (e.g. 1024x768).
# windowresolution -- Scale the window to this size IF the output device supports hardware scaling.
# output -- What to use for output: surface,overlay,opengl,openglnb.
# autolock -- Mouse will automatically lock, if you click on the screen.
# sensitiviy -- Mouse sensitivity.
# waitonerror -- Wait before closing the console if dosbox has an error.
# priority -- Priority levels for dosbox: lowest,lower,normal,higher,highest.
# Second entry behind the comma is for when dosbox is not focused/minimized.
# mapperfile -- File used to load/save the key/event mappings from.
# usescancodes -- Avoid usage of symkeys, might not work on all operating systems.

fullscreen=false

and change it to:

fullscreen=true

This will set the startup of DOSBOX to be fullscreen. This is vital for especially running Turbo C++ since under windowed mode its keyboard shortcuts Alt+F9 do not work since this key combination is used for minimizing windows,

You can also increase the processing power by increasing the value of cyles. DO NOT increase the value sohigh that the system does not handle. Keep it in range of 3000-20000.

Save the configuration files and close it.

Now when you run DOSBOX, it will automatically run in fullscreen and show your ‘dos’ directory files inside its C:

The next thing is needed is to solve another keyboard shortcut problem. Under Turbo C++ Crtl+F9 links and executes programs but this is also a keyboard shortcut of DOSBOX to immediately terminate itself. You could map DOSBOX. But as a better approach you can avoid this tedious work and download my mapper.txt which changes DOSBOX’s primary shortcut key from Crtl to Shift. Now Shift+F9 will terminate DOSBOX and thus you can use Crtl + F9 to link your Turbo C++ program.

DOWNLOAD THE MAPPER FILE HERE

Now download this mapper.txt file here and copy it the root of the home drive,i.e. your home directory itself.

Now you need to create a launcher for Turbo C++ so that you can double-click and run it.

1) In the desktop, right click and choose ‘Create Launcher’

2) Keeping the type as application, name it as Turbo C++ IDE.

3) In the command type dosbox -c C:\\TC\BIN\\TC.EXE -c EXIT

4) In the Comments type: Thank you, The Ubuntu Labrador ;-)

5) Choose any icon and create your launcher.

6) Now you can double click and run Turbo C++ IDE.

If you face any problems, or have any suggestion or query or comments you can comment here.

15 Responses to "Using DOSBOX to run Turbo C++ in Ubuntu Linux"

Thank you very much……It works fine…..Really Great work man…..Keep Rocking…..

Hi
Thanks for the tutorial. But I got a problem in compiling C++ program in DOSBox. It tells me that It can’t create some *.dpr file in the terminal in ubuntu.

Abhinav

@Abhinav
Do you have write permission in that folder?
You can:
Run Terminal:
chmod 777 foldername

Hope that helps

Thanks for commenting in my blog :D

Hi
Thanks for the solution. I am actually doing this for my school. We got two communities in our school, 1) Windows Community and 2) Linux Community. So as the leader of Linux Community I have to prove the principal that Linux is much better than Windows.
Thanks for the solution again

Abhinav

thank you so much!

Hi, I am running Ubuntu Linux Virtually, using vmware player. Now, i followed your instructions but it did not work for me.

Default Driver Letter it shows is: Z: drive

When i try to mount C:, it gives error, C: does not exist..

It does not make sense to me, since I am mapping C: of windows, I Suppose…

Can u solve my problem..
I also used dos emulator.. It loads with default C prompt, how should I proceed furthure… I have tried numerous ways, but those do not work, can U suggest something.. When I check C: directory it shows:
AUTOEXEC BAT
CONFIG SYS
TMP DIR

dosemu did not work for me when I tried it. It crashed too often.
As for your problem, to which directory are you mounting C:? Check whether that the directory exists.

Thanks..

it’s really help me, cause i need to run Turbo C++ under Vista in fullcreen mode :)

Hi
You did excellent work, I appreciate your work

I did according to your steps but its not supporting none of the unix command after running dosbox and even I have created c++ IDE on desktop their also after clinking on the icon the dialog box is coming for a while and again its going off.

please let me know where am going wrong

thank you very much
it worked fine .but i have problem .i have installation file of tc++.
i kept it in bin folder and made it run to install tc++.
when it asked for source drive i changed it from default A to C .but when i started installation it gave following msg:

please insert disk
#1
into drive C:

what i have to do?
waiting for quick reply

Hi i have installed dosbox and ran turboc from it. i cant use following keys in turboc
delete
home
end
pageup
pagedown
arrow keys
can i change mappeer.txt
how?

Hi i have installed dosbox and ran turboc from it.
It works fine .But i cant use following keys in turboc
delete
home
end
pageup
pagedown
arrow keys
As Yogesh Bhumkar said.

Hi there!

Thanks, I was looking a while for something like this.
But, how could I make a mapper file to adjust it for my keyborad?

Greetings

Hi, Thnaks for the solution. It works fine. But i am also facing the same problem. I cant use following keys in turboc
delete
home
end
pageup
pagedown
arrow keys
can anyone help.
thanks

Thanks a lot!!!
thats all done……

but the compiler doesn’t include the header files…
and none of the pre-defined functions are working??
how do u solve that??

Leave a Reply

Pages

 

July 2007
M T W T F S S
« Jun   Apr »
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

a

Archives

Visitors Count

  • 28,147 hits