Inside Out

Notes on seeking wisdom and crafting software

Running Turbo C code in Gnu C Compiler

One of the big problems that a majority of C programmers face is about transferring the Turbo C codes onto the gcc compiler in a linux box. Most of us learn C programming in the windows environment and when we go to the Linux environment we miss several of the Turbo C functions e.g : clrscr() (widely used for clearing the screen !).

Well fortunately there is a solution for this compatibility problem between Turbo C and gcc. And it is the flexibilty of linux that helps us to run old outdated Turbo C codes in linux box. There are two great packages that help us implement the functions ofTurbo C header files in gcc compiler with the Turbo C function names unchanged ::

1. [TurboC](

In order to implement functions of the Header files : Graphics.h Conio.h etc.. the full list is here . Just download the archive file and the complete installation instructions are here. Go to the directory, make the package and then do

> ln -s \*.h /usr/include >


> ln -s libTurboC.a /usr/lib

(i am assuming you are in the su mode)

Then try compiling the program. If it shows some error like “Symbolic links too deep” then try something like

ln *.h /usr/include

ln libTurboC.a /usr/lib

The to run a program just include the header files as usual and then

gcc <filename> -o <filename>-lTurboC -lm -lncurses -L/usr/X11R6/lib -lX11 -lpthread

The conio.h functions do work very well in this setup. For me the graphics.h functions dint work :-( However you can write a shell script to execute the long gcc command !!

1. [libgraph](

This is the gem package which let me run most of the graphics.h functions. Get the libgraph-1.0.1.tar.gz

[]( extract the files into some directory. Let it be /root/libgraph-1.0.1 (since i am working as root). Then open a terminal and better go to the superuser mode with su - and then type in root password.

Get the following packages (dependancies) :






All these packages are for OpenSuSE 32bit. Please search for the required rpms at

and the required packages for your box.

Then install these packages one by one :-)

Install the rpm’s by typing :

rpm -Uvh <filename>

and the tar.gz by extracting first and then typing (inside the directory containing the source files):

./configure;make;make install

At this stage i got an error *"Unable to find libstdc++.\* in location /usr/local/lib"*. Well the trick that worked for me was i just made a symbolic link of the files /usr/lib/libstdc++.\* in the directory /usr/local/lib with the command :

ln /usr/lib/libstdc++.* /usr/local/lib

Well untill this stage it worked fine. Now when i tried to compile a random [C-graphics file]( with the command

gcc <filename> -o <filename without extension> -lgraph

Good work !! The file compiles without any error :-)So lets run that :

./<filename without extension>

Here it showed some error : "./tst: error while loading shared libraries: cannot open shared object file: No such file or directory"

./tst is my executable file got after compiling the program with gcc.So now i created a backup of the files named libgraph.* in /usr/lib :

md /root/backup

cp /usr/lib/libgraph.\* /root/backup

Now i can safely play around with the libgraph.\* files ;-) Copy the libgraph.\* files onto the /usr/local/lib :

cp /usr/local/lib/libgraph.* /usr/lib

Now run the program.....and it runs :-)

technorati tags: graphics.h, gcc graphics, conio.h, clrscr(), unix