Step by step Graphics.h Solution for vs code

Admin

Requirements

Vs Code with Mingw must be installed.

Download Required library files

  • graphics.h
  • winbgim.h
  • libbgi.a

Download attached files

Copy "graphics.h" and "winbgim.h" files to "include" folder of MinGW

C:\MinGW\include

Copy "libbgi.a" to file to "lib" folder of MinGW

C:\MinGW\lib 

Open vs code select .vscode folder Available on the top of task panel

Create Tasks.json and paste below command.


{
	"version": "2.0.0",
	"tasks": [
		{
			"type": "cppbuild",
			"label": "C/C++: g++.exe build active file",
			"command": "C:\\MinGW\\bin\\g++.exe",
			"args": [
				"-fdiagnostics-color=always",
				"-g",
				"${file}",
				"-o",
				"${fileDirname}\\${fileBasenameNoExtension}.exe",
				"-lbgi",
				"-lgdi32",
				"-lcomdlg32",
				"-luuid",
				"-loleaut32",
				"-lole32"
			],
			"options": {
				"cwd": "${fileDirname}"
			},
			"problemMatcher": [
				"$gcc"
			],
			"group": {
				"kind": "build",
				"isDefault": true
			},
			"detail": "compiler: C:\\MinGW\\bin\\g++.exe"
		}
	]
}
Save tasks.json
  • Now Go to Terminal
  • Configure Default Build Task...
  • Select C/C++:g++ built active files


Create a file circle.cpp


#include <graphics.h>
int main()
{
	int gd = DETECT, gm;
	initgraph(&gd, &gm, "");
	circle(250, 200, 50);
	getch();
	closegraph();
	return 0;
}

Now Press ctrl+shift+b 

Code Runner Dosn't  Work here You have to use ctrl+shift+b to Run program



Use NULL Instead of "" to remove warning
 initgraph(&gd, &gm, NULL); 
To Open this file go to folder where your program is saved. a new file with .exe extension will created with same name as program is saved click on it to open.

if you are getting error means you haven't selected right C/C++:g++ built active files so try to change default build task and then ctrl+shift+b to build .Or Just change Label C/C++: g++.exe build active file to C/C++: g++.exe build Graphics active file and choose this one On default build Task.

Or the error related to MinGW just download my MinGW Backup and paste it on C:\ . 
Download MinGW backup With Graphics.h this can we useful of C++ and C too. 
If you are still getting errors comment below we will definitely help you

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.