I have add graphics.h
and winbgim.h
libraries, and also libbgi.a
to MinGW. They can all be found here. The archive has folders that indicate the directory where they should be placed under /MinGW
. I have also added -lbgi -lgdi32 -lcomdlg32 -luuid -loleaut32 -lole32
to extra link options, as specified in the following link: http://www.infobits.ro/medii-mingw-developer-studio3.php. (Sorry, it's in Romanian, but the images are quite easy to understand).
When I try to run the following code:
#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;
}
I get an error log with "undefined reference error". The error log is:
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)'
Any idea?