SFML crashes at first call using Code::Blocks - c++

I am using SFML 1.6 with Code::Blocks 12.11 on a windows 8.1 computer. I have been having problems so I made a very simple test program, which looks like this:
#include <iostream>
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
int main(){
std::cout<<"Start"<<std::endl;
sf::Sprite test;
std::cout<<"End"<<std::endl;
return 0;
}
When I try to run this it prints Start, then crashes. I have checked my linker settings and I think they are right because it compiles just fine with no errors or warnings. Is there something I'm missing?

I actually missed the fact that you're running SFML 1.6. I've tried your code with the latest build from GitHub and it runs just fine. Either this is some bug in 1.6 or you're doing something wrong somewhere else (you shouldn't see any program window unless you're creating one yourself).
Try downloading the latest version (2.1) from the downloads page and see whether it crashes as well. Right now I guess it crashes due to the incompatibility mentioned in this question/answer. Try running g++ -v from the command line to determine the exact version of GCC you're running.

Related

How can I get VSCode to find gmp.h after it has been successfully installed on Windows 10?

After installing and following the instructions for GMP (using mingw64 since I am on windows) and verifying the installation was correct using make check I tried running the following code in VSCode using the command g++ -g \path\file.cpp -lgmpxx -lgmp -o \path\file.exe:
#include <gmp.h>
#include <iostream>
using namespace std;
int main()
{
mpz_class a,b,c;
cout << "Hello World\n";
a = 1234;
b = "5678";
c = a+b;
return 0;
}
But get the error error: 'mpz_class' was not declared in this scope. So the include path in VSCode is incorrectly set up or the installation was messed up. I am wondering how to fix this: is this VSCode's includePath (compilerPath is not set up), an installation issue (I could not determine the default install location for windows systems since everything I found was for Linux), or is there something else I missed? I saw a flag for ./configure that was --enable-cxx but I wanted to ask before running make clean and retrying with that flag turned on since it takes forever.
I feel like this is something dead simple since I cannot find any help from googling.
Thank you for any help!
EDIT: I have tried running the code not in VSCode and it still has the same issue so I am not so sure it's VSCode.
I don't know anything about GMP, but you seem to include the wrong header.
#include <gmpxx.h> worked for me.

Eclipse C++ Setup

I want to switch from Dev-C++ to Eclipse (Version 12/18, 4.10.0) , but I am not able to Compile in Eclipse. I installed MinGW, edited the Pathvariable, restared the PC, installed the C++ Eclipse IDE, created a new Project there I choosed MinGW as my Compiler, and wrote a Hello World.
The Code is:
#include<iosteam>
using namespace std;
int main(){
cout << "Hello World!";
return 0;
}
The Error Message I get is the following:
error: CreateProcess: No such file or directory
What do I need to do to be able to build/run Proramms?
Thanks in advance
You have everything you need to be able to build/run programs. Maybe something is flawed in the configuration. You should separate the tasks to find out the problem.
First try to compile your minimal example by executing g++ from a console like that:
g++ main.cpp. If you get the same error message then you have to fix your Mingw-w64 setup.
If this works, then something is wrong with eclipse. You might want to check different project types. When using Makefile projects, you perhaps have more possibilities to do checks on the console.

C++ Quantlib EXC_BAD_ACCESS in Xcode

I've been trying to run some of the example code (BermudanSwaption) in Xcode but keep getting an EXC_BAD_ACCESS code=2.
But compiling and running the BermudanSwaption code in the terminal works correctly.
The following code throws the same error in Xcode.
#include <ql/quantlib.hpp>
#include <iostream>
using namespace QuantLib;
int main (){
Date date(18, March, 2014);
std::cout << date << std::endl;
}
And this runs correctly.
g++ -I/opt/local/include/ -I/opt/local/include/boost main.cpp -o main -L/opt/local/lib/ -lQuantLib
Are there some specific settings I need to tweak in Xcode in order for this to run?
I found that #including the individual libraries separately rather then including ql/quanlib to work. So in my example sub ql/quantlib.hpp with ql/time/date.hpp and everything runs fine.
Following the suggestion of Kaush, and a bit of trial and error, the following works for me in QuantLib 1.4, and means you don't have to add in every single individual library:
In <ql/experimental/models/all.hpp>, comment out these lines:
#include <ql/experimental/models/kahalesmilesection.hpp>
#include <ql/experimental/models/markovfunctional.hpp>

Codeblocks outputs broken executable

I have downloaded plenty of different versions of code blocks, and none of them compiles quite right. My hello world runs within code blocks just fine. However, when I run the executable outside of codeblocks, it says "Hello.exe has stopped working". There isn't anything wrong with my code (I don't think.) and my mingw compiles fine outside of codeblocks. What does codeblocks do to my executable? Is there some option to fix this? I am on windows 7 64 bit, and my current code blocks version is 10.05. My program:
#include <iostream>
using namespace std;
int main()
{
cout << "Hello world!" << endl;
cin.ignore();
return 0;
}
I solved the problem. I had a broken compiler (or something like that). My suggestion for other people with this problem is to experiment with different versions of the minGW compiler. Also, change the version of code blocks you are using, or even uninstall everything and restart. The problem with mine was I downloaded a bad compiler. [The truth is, codeblocks isn't the best ide.]

mingw produces broken .exe

I have installed the newest MinGW suite. My project still compiles without any error but the produced executable is not working. Starting it results in the well known windows xp error message. Paradoxically source code like
#include <stdio.h>
int main()
{
printf("test\n");
return 0;
}
produces a working executable while
#include <iostream>
int main()
{
std::cout << "test\n" << std::endl;
return 0;
}
compiles fine but the executable is broken as described above.
Before i made the update everything worked. So what goes wrong here?
Do you have the libstdc++-*.dll in the path? It may be shared in newer MinGW versions, and std::cout uses it.
A tool like Process Monitor will probably tell you what is actually going wrong in more detail, and possibly even tell you what you need to fix to make it work.