0

I want to run <graphics.h> in VsCode. For that, i downloaded the 3 files(graphics.h, winbgim.h and libbgi.a) and pasted them in their respective folders and the sqqiggly lines under graphics.h are not coming anymore. But when I go to execute the following code -

#include<graphics.h>
int main()
{   

int gd=DETECT,gm;
initgraph(&gd,&gm,(char*)"");

circle(200,200,100);
line(200,500,45,485);
getch();
closegraph();
return 0;
}

errors pop out as follows -

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Try the new cross-platform PowerShell https://aka.ms/pscore6

PS C:\Users\me\Documents\C++ programs> cd "c:\Users\me\Documents\C++ programs\graphics\" ; if ($?) { g++ temp.cpp -o temp } ; if ($?) { .\temp }
C:\Users\me\AppData\Local\Temp\ccLUwEoL.o:temp.cpp:(.text+0x27): undefined reference to `initgraph' 
C:\Users\me\AppData\Local\Temp\ccLUwEoL.o:temp.cpp:(.text+0x3c): undefined reference to `circle'    
C:\Users\me\AppData\Local\Temp\ccLUwEoL.o:temp.cpp:(.text+0x57): undefined reference to `line'      
C:\Users\me\AppData\Local\Temp\ccLUwEoL.o:temp.cpp:(.text+0x66): undefined reference to `closegraph'
collect2.exe: error: ld returned 1 exit status

Can anyone tell me what I did wrong? Also now I cannot install dev c++ or codeblocks because of a messy uninstallation of them a few days back.

genpfault
  • 51,148
  • 11
  • 85
  • 139
  • 1
    ***Can anyone tell me what I did wrong?*** Possibly forgot to modify `tasks.json` to link to the winbgi library and setup its include path. Also `c_cpp_properties.json` would need to be updated for Intellisense. Maybe also did not use a compiler from 15 or so years ago since the last binary of this library that I know about was in 2005. And uses gcc-3.4.5: [https://winbgim.codecutter.org/](https://winbgim.codecutter.org/) – drescherjm Apr 08 '21 at 11:23
  • 1
    This will help complete setup for graphics library in vs code using MinGW [link](https://github.com/ullaskunder3/Solution-to-graphics.h) – ullas kunder Jun 11 '21 at 11:10
  • 1
    Thanking you @ullaskunder for such detailed explanation....You made the working on graphics in VSCode so much easier... – ArtyisticSpinyFusion Jun 18 '21 at 06:35
  • Your welcome... keep coding, keep learning – ullas kunder Jun 18 '21 at 08:44

0 Answers0