我想在dev C++ 5.7.1中使用graphics.h。graphics.h在dev C++中不工作
我已經在網上搜索了可用選項。 我下載的包括文件夾中的graphics.h中庫,並選擇在參數選項如下:
-lbgi
-lgdi32
-lcomdlg32
-luuid
-loleaut32
-lole32
我仍然想不通爲什麼它顯示我這些錯誤:
undefined reference to `initgraph'
undefined reference to `graphresult'
undefined reference to `grapherrormsg'
undefined reference to `getmaxx'
undefined reference to `getmaxy'
undefined reference to `getmaxcolor'
undefined reference to `getcolor'
undefined reference to `circle'
undefined reference to `closegraph'
[Error] ld returned 1 exit status.
這是我的代碼:
#include<iostream>
#include<graphics.h>
#include<stdlib.h>
#include<stdio.h>
//#include<conio>
int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int midx, midy;
int radius = 100;
/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "C:\\Program Files (x86)\\Dev-Cpp\\MinGW64\\include\\winbgim");
/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk) /* an error occurred */
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* terminate with an error code */
}
midx = getmaxx()/2;
midy = getmaxy()/2;
setcolor(getmaxcolor());
/* draw the circle */
circle(midx, midy, radius);
/* clean up */
getch();
closegraph();
return 0;
}
我假設你使用[WinBGIm](http://winbgim.codecutter.org/)。您是否按照安裝說明將libbgi.a文件放入庫目錄中? – 2014-12-07 09:43:53
是的,我正確地按照所有的安裝說明進行操作。所有的文件都放置在應有的位置。 – 2014-12-07 10:29:38
@AvniSingh你有使用'Dev-C++'的具體要求嗎?如果沒有,我建議去'SFML',因爲它提供了比'Dev-C++'更多的***功能。 *哦,是的,你也可以很容易地在其中繪製圓圈。* – cybermonkey 2014-12-07 11:20:41