0

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?

genpfault
  • 51,148
  • 11
  • 85
  • 139
Mihai Bujanca
  • 4,089
  • 10
  • 43
  • 84
  • 1
    You're missing some lib – DGomez Apr 19 '13 at 20:27
  • Again, sorry the page is in romanian, but I did everything according to the specifications there.. I don't know what should I do – Mihai Bujanca Apr 19 '13 at 20:28
  • Perhaps compiling with gcc and not g++? That affects want standard library is linked in. – Bo Persson Apr 19 '13 at 20:28
  • which g++ version are you using?? http://www.linuxquestions.org/questions/linux-newbie-8/gnu-doesnt-seem-to-recognize-libstdc-373052/ – DGomez Apr 19 '13 at 20:30
  • The version is 2.05. MinGW finds the gcc and automatically compiles with it. All I can specify in the "compiler" ab is the path of the compiler. – Mihai Bujanca Apr 19 '13 at 20:31
  • 1
    http://stackoverflow.com/questions/6404636/libstdc-6-dll-not-found, check this – DGomez Apr 19 '13 at 20:35
  • Sorry, but the library you are trying to use is an ancient piece of crap. It was built with very old MinGW, and therefore relies on very old runtime library. If you are using one of the latest MinGW releases, then you'll never link against that ancient crappy library. So you have 2 choices: 1) abandon using that library, 2) rebuild it from sources with your current MinGW distribution. By the way, which version of MinGW do you use? Furthermore, **never ever** install 3rd party libraries into MinGW distribution. The toolchain is a stand-alone distribution and should remain virgin. – Alexander Shukaev Apr 19 '13 at 22:46
  • @Haroogan I do know that it is an ancient piece of crap, fully agreed with that. I just wait until my teacher realises this, to be honest. Again, I installed it because my teacher asked me to, and gave me tat link to follow the steps. I am using the 2.05 version – Mihai Bujanca Apr 20 '13 at 17:47
  • Oh, I see. I know firsthand how horrible it is to do some tasks imposed by tutors at university or school because their content is usually incredibly outdated. You won't believe it, but around 4 years ago when I was a 2nd year student at the university, we were forced to do some god damn useless labs and homeworks in [Turbo C++](http://en.wikipedia.org/wiki/Turbo_C%2B%2B). Just look at the screenshot and be horrified. So it's still not that bad what you have to do now... I wish you some patience to overcome that **** `:)` – Alexander Shukaev Apr 20 '13 at 18:41
  • @Haroogan I do indeed need a lot of patience, thanks. An year ago we were forced to work with Borland C, looks just the same. And next year they want us to learn FoxPro. Just expecting that they will soon introduce Fortran or something – Mihai Bujanca Apr 20 '13 at 18:44

0 Answers0