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](http://www.sandroid.org/TurboC/index.html)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
The to run a program just include the header files as usual and thenln *.h /usr/include
ln libTurboC.a /usr/lib
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 !!
This is the gem package which let me run most of the graphics.h functions. Get the libgraph-1.0.1.tar.gz
[](http://download.savannah.nongnu.org/releases/libgraph/libgraph-1.0.1.tar.gz)then 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) :
SDL_image-devel-1.2.4-2.i586.rpm
All these packages are for OpenSuSE 32bit. Please search for the required rpms at http://rpm.pbone.net/index.php3
and the required packages for your box.
Then install these packages one by one :-)
Install the rpm’s by typing :
and the tar.gz by extracting first and then typing (inside the directory containing the source files):rpm -Uvh <filename>
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 :./configure;make;make install
Well untill this stage it worked fine. Now when i tried to compile a random [C-graphics file](http://arun.zeeblo.com/files/test.c) with the commandln /usr/lib/libstdc++.* /usr/local/lib
Good work !! The file compiles without any error :-)So lets run that :gcc <filename> -o <filename without extension> -lgraph
Here it showed some error : "./tst: error while loading shared libraries: libgraph.so.1: cannot open shared object file: No such file or directory"./<filename without extension>
./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 :
Now i can safely play around with the libgraph.\* files ;-) Copy the libgraph.\* files onto the /usr/local/lib :md /root/backup
cp /usr/lib/libgraph.\* /root/backup
cp /usr/local/lib/libgraph.* /usr/lib
Now run the program.....and it runs :-)
technorati tags: graphics.h, gcc graphics, conio.h, clrscr(), unix