MacOSX: TurboC Installation

If you’d like to use C++ graphic features which is provided by “graphics.h” and “conio.h” , you should install several packages more to your MacBook. I assume that you already installed C compilers and X11 by Fink or other ways (Make sure “cc” command is working!) . You will also need ncurses package which you can easily install by fink as well. Then continue with the followings:

  1. Download TurboC binaries for MacOSx into your working directory.
  2. tar -xvf TurboC-dev.tar.gz
  3. cd TurboC-source
  4. Before running “make” command you may need to edit Makefile. (I remember that i’ve just added a space at the line starting with “hex2h:” as “-o $@” (not  -o$@)
  5. make

If your system is proper, you won’t get any warnings or error messages after installation. It is important to have “libTurboC.a” in your directory after installation. You have to include this file during compiling c++ files you created.

Now if you look at the structure it’s quite simple. If you locate your programs in the Programs directory which is created after installation, it will be easier for you to show the path.

I’m adding a simple code for you to test.


/*
*  circle.c
*
*
*  Created by Sinan Kuday on 26.02.2010.
*  Copyright 2010. All rights reserved.
*
*/
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include "../graphics.h"
#include "graphics.h"
#include "conio.h"

main(void)
{

int gd=DETECT, gm;
int poly[12]={350,450, 350,410, 430,400, 350,350, 300,430, 350,450 };
initgraph(&gd, &gm, "");
setcolor(3);
setfillstyle(SOLID_FILL,WHITE);
circle(100,100,50);
outtextxy(75,170, "Circle");
rectangle(200,50,350,150);
outtextxy(240, 170, "Rectangle");
ellipse(500, 100,0,360, 100,50);
outtextxy(480, 170, "Ellipse");
line(100,250,540,250);
outtextxy(300,260,"Line");
sector(150, 400, 30, 300, 100,50);
outtextxy(120, 460, "Sector");
drawpoly(6, poly);
outtextxy(340, 460, "Polygon");
getch();
closegraph();

}

You add this code in “circle.c” and compile it with the following command:
cd ..

cc -O0 -g -DWITH_X -I/usr/X11R6/include -o circle -I. Programs/circle.c -L. -L/usr/X11R6/lib -lTurboC -lncurses -lX11 -lm -lpthread

Then run it as usual way:
./circle

If you can see circles, polygons, …etc. in your X11 window, you are done!! Congrats.

About these ads

3 Responses to MacOSX: TurboC Installation

  1. Can you please post some more details, after the installation successfully how to compile a c program file created in any directory? or every time needs to be used CC long command?

    Regards

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: