Today we are going to see how to run C graphics program on 64 bits Windows 7 using CodeBlocks 13.12.
It will require only 12 steps. Follow with caution and you are done.
These are the instructions I have tried for 64 bits windows 7:
- Download zip
file from this repository: https://github.com/stahta01/windows-games
This one is having latest files of Graphics Libraries.
- Now either you
are using external GCC compiler or internal GCC compiler doesn’t matter, just follow the universal procedure recommended for this.
- Copy the following files
From(windows-games-master\WinBGIm)
|
To (MinGW)
|
include
folder => graphics.h
|
Include
|
src folder
=> Winbgim.h
|
Include
|
lib folder =>
libbgi.a
|
Lib
|
If any of the files are already at destination, please overwrite as these are going to work for 64
bits versions.
4. Now, go to Setting => Compile and Debugger => Selected Compiler => GNU GCC Compiler.
disturb other type of program execution.
5. Now in Linker
settings => Add => File => C:\MinGW32\lib\libbgi.a
6. Go to right part,
other settings paste these parameters:
-lbgi -lgdi32
-lcomdlg32 -luuid -loleaut32 -lole32
7. Now half of the
configuration has been done.
8. Create simple
empty project using codeblocks and add file with extension .cpp.
9. Most
IMPORTANT part is now:
Now, right click on Project Name => Build Options => selected Compiler.
You have
to select the compiler which you have configured.
Otherwise you will get:
i. Memory access violation error "Process-returned-1073741819-0xc0000005"
or
ii. Segmentation fault.
Otherwise you will get:
i. Memory access violation error "Process-returned-1073741819-0xc0000005"
or
ii. Segmentation fault.
After successfully completing above steps, try the following program with Hello.cpp
This is my sample program to print name of screen:
This is my sample program to print name of screen:
#include<graphics.h>
#include<conio.h>
main()
{
int gd = DETECT,gm,left=100,top=100,right=200,bottom=200,x= 300,y=150,radius=50;
initgraph(&gd, &gm, "C:\\TC\\BGI");
rectangle(left, top, right, bottom);
circle(x, y, radius);
bar(left + 300, top, right + 300, bottom);
line(left - 10, top + 150, left + 410, top + 150);
ellipse(x, y + 200, 0, 360, 100, 50);
outtextxy(left + 100, top + 325, "My First C Graphics Program");
getch();
closegraph();
return 0;
}
10. Now, rebuild the
project.
11. After that,
compile and run.
12. You will
definitely see such message printed,
Howdy --
ReplyDeleteI'm attempting to find libbgi.a in your windows-games, and don't see it. Could you point me towards this?
Many thanks,
David Small
Download this file it is having libbgi.a
Deletehttp://winbgim.codecutter.org/V6_0/WinBGIm_Library6_0_Nov2005.zip
these files don't work
Deletei followed your steps carefully, but when i run the program, it stops working.. A pop up window by Windows OS comes and "says "myprogram.exe" has stopped working. Windows is finding a solution for this"....
ReplyDeletethere is no lib folder . So no file named libbgi.a in the zip.
ReplyDeletethanks, this way c gets compiled well with codeblock and when i run the compiled exe file my 64bit window 8.1 shows error message and shuts down it.
ReplyDeleteI have the same error on a Win 7 64bit system.
Delete