Search code examples
c++bgiwinbgi

BGI in updated wxDevCpp does not work


I need to use BGI graphics in my program and it worked just fine in the wxDevCpp 7.3. But now I installed an updated version of this IDE 7.4, did everything by instruction http://www.cs.colorado.edu/~main/bgi/dev-c++/, just like before, but now when I try to compile any simple program like

#include <graphics.h>

int main( )
{
    initwindow(400, 300, "First Sample");
    circle(100, 50, 40);
    while (!kbhit( ))
    {
        delay(200);
    }
    return 0;
}

I get multiple errors saying that

initwindow(), circle(), kbhit(), delay()

were not declared in the scope. I have no idea what to do. The change in updated wxDevCpp is the different folder structure, but I copypasted the graphics.h and libbgi.a in several folders. I did not forget to add the linker commands just as the instruction said, but it does not work. Also, I found another graphics.h which came along with installation of new wxDevCpp and though it might bring a conflict, so I just removed it. No change :(


Solution

  • I think I solved it! It was actually trouble with the graphics.h When I copypasted all the graphics.h into my .cpp, the compiler gave an error that int right was declared twice in the following code:

    void printimage(
        const char* title=NULL, 
        double width_inches=7, double border_left_inches=0.75, double border_top_inches=0.75,
        int left=0, int right=0, int right=INT_MAX, int bottom=INT_MAX,
        bool active=true, HWND hwnd=NULL
        );
    

    redefinition of int right, so as it is just a prototype, I change it to:

    void printimage(
        const char* title=NULL, 
        double width_inches=7, double border_left_inches=0.75, double border_top_inches=0.75,
        int left=0, int right=0, int=INT_MAX, int bottom=INT_MAX,
        bool active=true, HWND hwnd=NULL
        );
    

    Now it works!!!