Get BGI Graphics To Work In Dev-Cpp

Discussion in 'C' started by blitzcoder, Aug 25, 2010.

  1. blitzcoder

    blitzcoder New Member

    Joined:
    Aug 24, 2010
    Messages:
    12
    Likes Received:
    2
    Trophy Points:
    0
    Occupation:
    Student
    Location:
    Surat, India
    Home Page:
    http://shreyagarwal.blog.com
    Dev-Cpp is an application which is used to code and run programs in C/C++. It has its variations but none of them come with a pre-installed graphics library. So if you are switching from some primitive editor like TurboC to Dev-Cpp (which follows ANSI specifications correctly) and try to write the following code, it won’t compile.

    Code:
    #include<iostream>
    #include<graphics.h>
    using namespace std;
    int main()
    {
    	int gm=DETECT, gd;
    	initgraph(&gm,&gd,”C:\\Dev-Cpp\\lib”);
    	cleardevice();
    	circle(200,200,50);
    	getch();
    	closegraph();
    	return 0;
    }
    
    You will get an error saying “Could not find graphics.h”.

    What you need to do is visit the following link, and download the file

    http://tinf.ti.funpic.de/_nicht_loeschen/WinBGIm-6.0-1g17l.DevPak

    You will have to install it. The problem is that it sometimes experiences a malfunction, in which case you open it with “WinRAR” (or an equivalent software) and just extract “graphics.h” to the include directory of your Dev-Cpp installation.

    Now, when you create a project, go to Project->Project Options and select the Parameters tab. In this, under the “Linker” field, type in the following. (including the ‘-’)

    -lbgi
    -lgdi32
    -lcomdlg32
    -luuid
    -loleaut32
    -lole32


    And voila! Once you have this installed and the above changes made, you do not need anything more and can simply run the above code to test it. Now get started with writing whatever code you want, using your newly acquired “graphics.h” functions! :)
     

    Attached Files:

  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    How do we install that file?
     
  3. blitzcoder

    blitzcoder New Member

    Joined:
    Aug 24, 2010
    Messages:
    12
    Likes Received:
    2
    Trophy Points:
    0
    Occupation:
    Student
    Location:
    Surat, India
    Home Page:
    http://shreyagarwal.blog.com
    It is a simple installation file. Just run it and keep clicking next. That is all :)
     
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
  5. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
  6. wdliming

    wdliming New Member

    Joined:
    Sep 26, 2010
    Messages:
    28
    Likes Received:
    0
    Trophy Points:
    0
    when i did as you tell me ,but i could not complie successfully.
    my code is \;
    int main(int argc, char *argv[])
    {
    int gm=DETECT, gd;
    initgraph(&gm,&gd,"D:\\DEV-CPP\\lib");
    cleardevice();
    circle(200,200,50);
    getch();
    closegraph();
    system("PAUSE");
    return EXIT_SUCCESS;
    }
    it says:
    D:\DEV-CPP\Examples\Graghics\main.cpp `D' was not declared in this scope(i install the dev c++ in the D:\DEV-CPP)
    could you tell me how to amend it?Thank you!!
     
  7. wdliming

    wdliming New Member

    Joined:
    Sep 26, 2010
    Messages:
    28
    Likes Received:
    0
    Trophy Points:
    0
    sorry!i am so caraless that i didnot change the " " ",at first i input the " " " in Chinese mode.Now i eat my words ,and i make it,thank you!!:)
     
  8. seoguru

    seoguru New Member

    Joined:
    Oct 6, 2010
    Messages:
    19
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    http://www.seofleet.com
    One of the most important aspects of on-page SEO (Search Engine Optimization) these days is site speed (on-page SEO consists of the factors you change/implement on your Web site itself, such as changing title tags, posting content, etc.). In other words, how fast does your Web site load when someone visits it? Is it image-intensive? If so, do you extend the courtesy of letting your visitors click on a thumbnail to load a full image
     
  9. glen

    glen New Member

    Joined:
    Nov 13, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    This does not work for me.
    I have a working copy of 4.9.9.2
    graphics.h loaded in proper place
    When trying to compile test code, I get a compile error on the initgraphics line.
    I'm unable to goto Project/project options- error box comes up.
    [​IMG]Can't post image here, or attach so I can't show you what the error message is.
    The error box is called Oops, and it says An unexpected error has occurred in the application.
     
  10. Mohamed IBrahim

    Mohamed IBrahim New Member

    Joined:
    Oct 25, 2010
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    thank you very much
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice