我已将graphics.h
和winbgim.h
库以及libbgi.a
添加到MinGW。他们都可以找到here。存档具有文件夹,指示应将其放置在/MinGW
下的目录。我还将-lbgi -lgdi32 -lcomdlg32 -luuid -loleaut32 -lole32
添加到了额外的链接选项,如以下链接中所指定:http://www.infobits.ro/medii-mingw-developer-studio3.php。 (对不起,这是罗马尼亚语,但图片很容易理解)
当我尝试运行以下代码时:
#include <graphics.h>
#include <iostream>
using namespace std;
int main() {
int gdriver = DETECT, gmode;
initgraph(&gdriver, &gmode, "");
if (graphresult()) {
cout<<"Tentativa nereusita ...";
}
else {
cout<<"Everything is working!";
setcolor(RED);
moveto(0,0);
lineto(getmaxx(),getmaxy());
}
cout<<endl<<"Press anything to close";
getch();
return 0;
}
我收到错误日志,其中包含“未定义的引用错误”。错误日志是:
C:\OJI\MinGWStudio\MinGW\bin\..\lib\gcc-lib\mingw32\3.3.1\..\..\..\libbgi.a(winbgi.o)(.text+0xbd2):winbgi.cxx: undefined reference to `std::string::_Rep::_S_empty_rep_storage'
C:\OJI\MinGWStudio\MinGW\bin\..\lib\gcc-lib\mingw32\3.3.1\..\..\..\libbgi.a(winbgi.o)(.text+0x1b5e):winbgi.cxx: undefined reference to `std::string::_Rep::_S_empty_rep_storage'
C:\OJI\MinGWStudio\MinGW\bin\..\lib\gcc-lib\mingw32\3.3.1\..\..\..\libbgi.a(winbgi.o)(.text+0x1dcc):winbgi.cxx: undefined reference to `__gnu_cxx::__exchange_and_add(int volatile*, int)'
C:\OJI\MinGWStudio\MinGW\bin\..\lib\gcc-lib\mingw32\3.3.1\..\..\..\libbgi.a(winthread.o)(.text+0x522):winthread.cxx: undefined reference to `std::string::_Rep::_S_empty_rep_storage'
C:\OJI\MinGWStudio\MinGW\bin\..\lib\gcc-lib\mingw32\3.3.1\..\..\..\libbgi.a(winthread.o)(.text+0x57e):winthread.cxx: undefined reference to `__gnu_cxx::__exchange_and_add(int volatile*, int)'
有什么想法吗?