I'm trying to run this program on through gcc
on Windows shell.
GCC version that I'm using:
gcc (i686-posix-dwarf-rev0, Built by MinGW-W64 project) 8.1.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
The code:
#include<stdio.h>
#include<graphics.h>
int main(){
int gd = DETECT, gm;
initgraph(&gd, &gm, "");
line(150,150,450,150);
getch();
closegraph();
}
At first, it was giving me this error:
fatal error: graphics.h: No such file or directory
#include<graphics.h>
Then I added the graphics.h
file to my gcc
directory.
But now it is showing this error:
Gph.C: In function 'int main()':
Gph.C:5:24: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
initgraph(&gd, &gm, "");
^
C:UserssimpleAppDataLocalTempcchdXkih.o:Gph.C:(.text+0x2e): undefined reference to `initgraph'
C:UserssimpleAppDataLocalTempcchdXkih.o:Gph.C:(.text+0x52): undefined reference to `line'
C:UserssimpleAppDataLocalTempcchdXkih.o:Gph.C:(.text+0x63): undefined reference to `closegraph'
collect2.exe: error: ld returned 1 exit status
Can someone suggest an alternative way to run my program? I've already tried running it on Visual Studio and Online Compilers.
question from:
https://stackoverflow.com/questions/65909961/unable-to-run-graphics-h-program-in-windows-shell 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…