我在C语言中使用此程序:http://rajababuman.blogspot.com/p/graphics-in-turbo-c.html。C在Linux中的C++图形程序
如果我在我的Win7机器上使用DOSBOX并使用TurboC++并显示它在做什么,它工作正常。但是,如何在Linux机器上运行以下图形程序(我们没有DOSBOX或turboC++)? PS:DISPLAY环境变量已经设置为我本地机器的IP地址,以便在Linux上显示GUI /图形框,即如果我运行“xclock”,时钟将成功显示在我的机器上。
我知道TURBO C是一个Windows工具,使用Windows API。
我不必使用graphics.h头文件,如果我可以在Linux机器上得到一个简单的C程序,当我编译时,它给了我相同的输出(因为这个程序给了我一个Windows机器)在Linux机器上(没有我安装/使用DOSBOX或TurboC)。
/////////////////////////////////////////////////////////////////////////////////////////
//Diagram of a car
///////////////////////////////////////////////////////////////////////////////////////
#include<stdio.h>
#include<graphics.h>
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"");
rectangle(100,200,200,250);
rectangle(220,200,320,250);
rectangle(90,190,330,290);
circle(150,290,30);
circle(270,290,30);
getch();
}
当我编译的Linux机器上这个节目,我收到以下错误:
[科巴@ server1的鹦鹉] $ GCC GC
g.c:2:21: error: graphics.h: No such file or directory
g.c: In function âmainâ:
g.c:5: error: âDETECTâ undeclared (first use in this function)
g.c:5: error: (Each undeclared identifier is reported only once
g.c:5: error: for each function it appears in.)
g.c:4: warning: return type of âmainâ is not âintâ
[科巴@ server1的鹦鹉] $
[科巴@ server1的洛里] $ CC GC
g.c:2:21: error: graphics.h: No such file or directory
g.c: In function âmainâ:
g.c:5: error: âDETECTâ undeclared (first use in this function)
g.c:5: error: (Each undeclared identifier is reported only once
g.c:5: error: for each function it appears in.)
g.c:4: warning: return type of âmainâ is not âintâ
[koba @ server1 lory] $
编译器似乎很难找到“graphics.h” – kiwixz 2014-12-05 23:15:47
那么在哪里的graphics.h? – 2014-12-05 23:16:37
graphics.h是一个非标准标题。看到这个问题 http://stackoverflow.com/questions/7860569/how-i-can-get-and-use-the-header-file-graphics-h-in-my-c-program – 2014-12-05 23:21:39