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)
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.
Related
I have a simple HelloWorld application
#include <cstdio>
int main(int argc, char * argv[]) {
printf("Hello world\n");
while (getchar() != '\n') {}
return 0;
}
I compiled it with MinGW on Windows 7 with command
g++ -static-libgcc -static-libstdc++ HelloWorld.cpp -o HelloWorld.exe
In my computer it runs well, but when i move it to another computer with clean Windows 8, it doesn't start. After double clicking it, it shows "loading" cursor and it's loading and loading ... and never starts console and executes, no error message. The process is not listed anywhere in task manager and if i try to delete the exe file, it says it's being used by process System. Only restart makes it possible to delete this file.
What is wrong? How can i compile a program for Windows 8 and later on my Windows 7?
EDIT: i compiled the program with Visual C++ 2008 compiler and it does the same.
I am just starting C++ and downloaded a compiler and an IDE, both eclipse, and tried to make my first C++ program. I use the Hello World C++ Makefile Project, and add the all the stuff on the next page. I then build the program, and the build says this:
12:30:00 **** Build of configuration Default for project HelloWorld! **** make all Cannot run program "make": Launching failed
Error: Program "make" not found in PATH PATH=[C:/Program Files
(x86)/Java/jre1.8.0_91/bin/client;C:/Program Files
(x86)/Java/jre1.8.0_91/bin;C:/Program Files
(x86)/Java/jre1.8.0_91/lib/i386;C:\ProgramData\Oracle\Java\javapath;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)\ATI Technologies\ATI.ACE\Core-Static;c:\Program Files
(x86)\Common Files\Roxio Shared\DLLShared\;c:\Program Files
(x86)\Common Files\Roxio Shared\12.0\DLLShared\;C:\Program Files
(x86)\Windows Live\Shared;c:\Program Files (x86)\Microsoft SQL
Server\100\Tools\Binn\;c:\Program Files (x86)\Microsoft SQL
Server\100\DTS\Binn\;C:\Users\Jen\Desktop\eclipse;] 12:30:00 Build
Finished (took 122ms)***
I run the program, and it says:
Launch failed. Binary not found.
This is the code for the program:
#include <stdio.h>
#include <stdlib.h>
int main(void) {
puts("Hello World!");
return EXIT_SUCCESS;
}
There are two errors, too:
Function "puts" couldn't be resolved.
Symbol "EXIT_SUCCESS" couldn't be resolved.
Thanks in advance!
Nate N.
/////////////////////////////////////////////////////////////////////////
I followed the advise of user4581301 and the code now says this:
#include <iostream>
using namespace std;
int main() {
cout << "Hi World" << endl; // prints Hi World
return 0;
}
The build looks like this:
13:22:26 **** Rebuild of configuration Debug for project HiWorld ****
Info: Internal Builder is used for build
g++ -O0 -g3 -Wall -c -fmessage-length=0 -o "src\HiWorld.o" "..\src\HiWorld.cpp"
g++ -o HiWorld.exe "src\HiWorld.o"
13:22:27 Build Finished (took 835ms)
But now the program, although it does run, doesn't print anything.
Thanks in advance,
Nate N.
Launch failed. Binary not found.
well this is shown because you have 2 errors.
any error means = no binary compiled/linked
no binary compiled/linked = cant launch something which doesnt exist
solution = fixing the errors
#include #include
^ also this is not valid
Cannot run program "make": Launching failed Error: Program "make" not found in PATH
Kaboom! No make, no build, no binary to run.
Some compilers don't ship with Make out of the box, but I don't see any signs of a compiler toolchain in your path at all.
Eclipse is an IDE with support for a wide variety of different compilers. as a result it does not ship with one. Since the error message shows you are building on Windows, your simplest option is one of the many MinGW variants. And Since you are just starting, I recommend starting off with the plain-vanilla MinGW as Eclipse requires next to no extra configuration to use it.
Just make sure you follow the instructions to install msys along with MinGW to get make.
I am trying to make a simple program with SFML. The source code is the same provided in this example
Given that I downloaded SFML from the site using the precompiled version from Visual Studio 12.
I configured the project normally, and added the correct libraries for debug and release.
Note:
There were no compiler errors, and not linker errors as well. I also added the .dll libraries in the .exe directory.
When I run the program, here is the output (just crashes):
Exception thrown at 0x50FAFA96 (sfml-system-d-2.dll) in TestSFML.exe: 0xC0000005: Access violation reading location 0xCCCCCCD8.
If there is a handler for this exception, the program may be safely continued.
From what I looked on the internet, this error seems to be related to mixing debug and release libraries, but I think I did it right.
Note that I am using Visual Studio Community 2015, but I don't think this could cause the problem.
The configuration inside the project
Release and Debug (All Configurations):
Added the same directory for the include path (release and debug) and library path (release and debug).
Release
On Linker -> Input I added:
sfml-window.lib
sfml-system.lib
Debug
On Linker->Input I added:
sfml-system-d.lib
sfml-window-d.lib
Since I am using dynamic libraries, I also added the libraries on the directory of the executable.
EDIT
Main.cpp
#include <SFML/Window.hpp>
#include <SFML/OpenGL.hpp>
int main()
{
// create the window
sf::Window window(sf::VideoMode(800, 600), "OpenGL", sf::Style::Default, sf::ContextSettings(32));
window.setVerticalSyncEnabled(true);
// load resources, initialize the OpenGL states, ...
// run the main loop
bool running = true;
while (running)
{
// handle events
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
{
// end the program
running = false;
}
else if (event.type == sf::Event::Resized)
{
// adjust the viewport when the window is resized
glViewport(0, 0, event.size.width, event.size.height);
}
}
// clear the buffers
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// draw...
// end the current frame (internally swaps the front and back buffers)
window.display();
}
// release resources...
return 0;
}
Aditional dependencies on the project. They were set on Active(Debug)
opengl32.lib
sfml-system-d.lib
sfml-window-d.lib
The compilation
1>------ Build started: Project: TestSFML, Configuration: Debug x64 ------
1> main.cpp
1> TestSFML.vcxproj -> C:\Users\Leonardo\documents\visual studio 2015\Projects\TestSFML\x64\Debug\TestSFML.exe
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
I got the same error when trying to compile a SFML program with SFML for VS2013 when using VS2015. Downloading (and obviously using) the correct version solved the problem.
I am using ffmpeg and Qt to build a small demo app.
FFmpeg is built with /MT (crossbuild or built with visual 2010)
Qt is always built with /MD
My little example is always built with /MD
When the application
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
av_gcd (75, 25);
return a.exec();
}
//note : following is av_gcd source in ffmpeg libs:
int64_t av_gcd(int64_t a, int64_t b)
{
if (b)
return av_gcd(b, a % b);
else
return a;
}
is executed in release mode it crashes because it doesn't see av_gcd as executable memory. The error is:
First-chance exception at 0x0000000300905a4d in mylittleexample.exe:
0xC0000005: Access violation at location 0x0000000300905a4d.
=======================================
VERIFIER STOP 0000000000000650: pid 0x1B9C: Attempt to execute code in
non-executable memory (first chance).
0000000300905A4D : Address being accessed. 0000000300905A4D : Code
performing invalid access. 00000000009FF770 : Exception record. Use
.exr to display it. 00000000009FF280 : Context record. Use .cxr to
display it.
=======================================
The address 0x0000000300905a4d doesnt change regardless of the function in the library (ffmpeg in this case), or the compiler used for the executable (vs2010, vs2012) or a different machine.
If I use the FFmpeg built with /MD and it works as one would expect.
I observe that the executable doesnt load the library when the
library is compiled with /MT. Why is that?
Furthermore, If the library is compiled with /MT and debug
information is enabled when the application is linked (/DEBUG
param to the linker) then the library is loaded and everything
execute correctly. Why?
Yesterday I decided to download, install, and attempt to use Allegro 5. I also downloaded Code::Blocks 12.11 w/ the MinGW compiler. I set up everything and installed everything correctly (or so I thought) and tried to run a sample code to see if it would work:
#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;
}
When I attempt to compile and run the program an error message box appears saying "The procedure entry point _gxx_personality_v0 could not be located in the dynamic link library libstdc++-6.dll." I searched the web for about an hour trying to find a fix for this problem, like I do for most things, but I came up empty handed. I'm wondering if anyone has any ideas for any fixes to this problem, if so, let me know ASAP! Thanks in advance!
__gxx_personality_v0 is used in the exception handling of the C++ library. MinGW can support a couple different exception models on the x86: sjlj (setjmp/longjmp) or DWARF (DW2). As far as I know, which model will be used is compiled into the compiler - it's not something that can be selected with a command line option.
The sjlj exception model will link to __gxx_personality_sj0, the DW2 exception model links to __gxx_personality_v0. It seems like your compiler is building for the dw2 exception model, but at runtime it's finding a libstdc++-6.dll that was built with the sjlj model. See if you have multiple versions of libstdc++-6.dll on youR system, and see if copying another one to the same directory as your program fixes the problem.
You can use nm libstdc++-6.dll | grep personality to see which exception 'personality' the DLL is using.
I ran into this as well. Did some searching, someone mentioned paying attention to whether or not you were in Debug or Release Mode. This applies to Code::Blocks specifically. I found I was in Debug Mode. I changed that to Release Mode and my program compiled and ran.
I am troubled by this though... It seems to me it should work in both modes, so how do I fix it so that it will? I have no answer there. Maybe someone will comment with the solution. In the meantime, compile and run in Release Mode instead of Debug Mode.
I just did a little mad science, removed the libstdc++6.dll from MinGW/bin and put it in another folder. Then I copied over the same file from Gimp/bin. No more linker error, instead I get an error that says the application failed to start :( Still compiles and runs in Release Mode though.