0

I was trying to compile and run the following code on my CODE::BLOCKS sftwr but It could never run properly due to some problems with a dll "libstdc++6.dll"

I leave you the code listing and the error log in debug mode (f8)

#include <stdio.h>
#include <allegro5/allegro.h> 

int main(int argc, char **argv){ 
    ALLEGRO_DISPLAY *display = NULL;
    if(!al_init()) {
        fprintf(stderr, "failed to initialize allegro!\n");
        return -1;
    }
    display = al_create_display(640, 480);
    if(!display) {
        fprintf(stderr, "failed to create display!\n");
        return -1;
    }
    al_clear_to_color(al_map_rgb(0,0,0));
    al_flip_display();
    al_rest(10.0);
    al_destroy_display(display);
    return 0;
}   

Debug output:

Building to ensure sources are up-to-date
Selecting target: 
Debug
Adding source dir: c:\telechar\Codeblocks\Mesprojets\MonProjet\
Adding source dir: c:\telechar\Codeblocks\Mesprojets\MonProjet\
Adding file: c:\telechar\Codeblocks\Mesprojets\MonProjet\bin\Debug\MonProjet.exe
Changing directory to: c:/telechar/Codeblocks/Mesprojets/MonProjet/.
Set variable: PATH=.;C:\Telechar\CodeBlocks\MinGW\bin;C:\Telechar\CodeBlocks\MinGW;
C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem;C:\Windows\System32\WindowsPowerShell\v1.0;c:\Program Files (x86)\Common  Files\Ulead Systems\MPEG;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files (x86)\Windows Live\Shared
Starting debugger: C:\Telechar\CodeBlocks\MINGW\bin\gdb.exe -nx -fullname  -quiet  -args c:/telechar/Codeblocks/Mesprojets/MonProjet/bin/Debug/MonProjet.exe 
done
Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints
Debugger name and version: GNU gdb (GDB) 7.5
Child process PID: 5536
Error while reading shared library symbols for c:\telechar\Codeblocks\Mesprojets\MonProjet\libstdc++-6.dll:
...
Error while reading shared library symbols for c:\telechar\Codeblocks\Mesprojets\MonProjet\libstdc++-6.dll:
Program received signal SIGSEGV, Segmentation fault.
In al_destroy_display () (c:\telechar\Codeblocks\Mesprojets\MonProjet\allegro-5.0.10-md.dll)
Continuing...
Program received signal SIGSEGV, Segmentation fault.
In al_destroy_display () (c:\telechar\Codeblocks\Mesprojets\MonProjet\allegro-5.0.10-md.dll)
Continuing...
[Inferior 1 (process 5536) exited with code 030000000005]
Debugger finished with status 0

the weird thing is that in release mode, it seems to work fine (a window appears for a while then closes itself, in debug mode, the screen displays but it has a blue color instead, at the end, it does crashes)

Cole Tobin
  • 9,206
  • 15
  • 49
  • 74
Shinobi
  • 231
  • 1
  • 3
  • 8
  • 1
    It may be related to using a version of Allegro compiled with a GCC version different from the one provided with CodeBlocks. See [this similar question on Stack Overflow](http://stackoverflow.com/questions/14901930/allegro-5-crashs-on-calling-al-clear-to-colorallegro-color) which points to [this forum thread](https://www.allegro.cc/forums/thread/610189) – Julien Oct 02 '13 at 13:13
  • my version de gcc is 4.7.1 , it cames with code::blocks. How could I use a new version of gcc with CD::BLCKS? I tried to donwload the latest version but I do not understand the donwloading process on their website – Shinobi Oct 02 '13 at 13:24
  • On windows you have to install MinGW (the Windows GCC port). – Appleshell Oct 02 '13 at 13:29
  • 1
    @Shinobi Do you use a precompiled version of Allegro or did you compile it yourself? – Julien Oct 02 '13 at 13:32
  • I use a precompiled version 5.0.10 for mingw 4.7.0, downloaded from the allegro website. I linked it to CODE::BLOCKS – Shinobi Oct 02 '13 at 13:44

1 Answers1

0

Following the comments of the question, I guess the problem comes from the fact that you use MinGW 4.7.1, provided with CodeBlocks, whereas your Allegro binaries are compiled for MinGW 4.7.0.

According to this similar question which point to this forum thread, the version of the compiler used for Allegro and for your program must be the same. Thus, you can either:

  • Download a version of Allegro compiled for MinGW 4.7.1,
  • or compile Allegro by yourself, using MinGW 4.7.1,
  • or use MinGW 4.7.0 instead of the version provided with CodeBlocks.
Community
  • 1
  • 1
Julien
  • 2,139
  • 1
  • 19
  • 32