ahmedshakill / WinBGIm-64

WinBGIm 64 bit compiler support .
28 stars 32 forks source link

How to include <graphics.h> rather than "graphics.h" | Unable to call include graphics.h globally #3

Open merajmasuk opened 2 years ago

merajmasuk commented 2 years ago

Hi, I was able to compile a graphics source file with graphics.h and the source being in the same directory. My current code is below (I didn't call any function as I'm just testing if the library is able to include):

#include "graphics.h"
main() {}

But I am not satisfied with this. My next goal is to be able to include graphics.h globally, rather than in a single project locally. My target is as follows:

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

But I'm receiving error such as "fatal error: graphics.h: No such file or directory".

To obtain second result, I copied WinBGIm-64\libbgi\include\bgi\graphics.h and WinBGIm-64\libbgi\include\bgi\winbgim.h to C:/Program Files/CodeBlocks/MinGW/include and WinBGIm-64\libbgi\libbgi.a to C:/Program Files/CodeBlocks/MinGW/lib. Then I ran the program.

My linker flags:

-lbgi
-lgdi32
-lcomdlg32
-luuid
-loleaut32
-lole32
-std=c++11
merajmasuk commented 2 years ago

How I built the library

I ran the following commands on cmd.exe

> cd WinBGIm-64
> set PATH=%PATH%;C:/Program Files/CodeBlocks/MinGW/bin
> cmake -G "MinGW Makefiles"
> cmake --build .
ahmedshakill commented 2 years ago

Hi Sorry for late reply. Were you able to solve your issue? I also faced it with newer version of GCC not finding 'graphics.h' directly from MinGW include . In that case , I moved graphics.h to the directory which contains other header files like 'iostream' or 'stdio.h' . They are in there somewhere ,a simple search can show the location , then just copy 'graphics.h' header there.

merajmasuk commented 2 years ago

Sorry, I went with 32 bit version. But I'm still eager to solve the issue and leave note for future readers. And yes, I copied the graphics.h header to C:/Program Files/CodeBlocks/MinGW/include. This is where it is supposed to go. Also the libbgi.a to the C:/Program Files/CodeBlocks/MinGW/lib folder. But simply doing this didn't help.

ahmedshakill commented 2 years ago

Let's try this Copy WinBGIm-64\libbgi\include\bgi\graphics.h and WinBGIm-64\libbgi\include\bgi\winbgim.h to the directory containing 'stdio.h' file which for 64 bit installation happens to be CodeBlocks/MinGW/x86_64-w64-mingw32/include

Let me know if it works

217eastbroadway commented 1 year ago

To make outtextxy and all other text display functions work, you'll need to recompile the project in C++14.