Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Trying to set up SFML 1.6 in Code::Blocks, but getting segmentation fault  (Read 3698 times)

0 Members and 1 Guest are viewing this topic.

Midleiro F

  • Newbie
  • *
  • Posts: 14
    • View Profile
I'm using the static version, I put
-lsfml-graphics
-lsfml-window
-lsfml-system
under linker options, defined SFML_DYNAMIC, placed the dll's in the exe folder and everything.

My mingw version is 4.70.

I tried to run the following program :
#include <SFML/System.hpp>
#include <iostream>

int main()
{
    sf::Clock Clock;
    while (Clock.GetElapsedTime() < 5.f)
    {
        std::cout << Clock.GetElapsedTime() << std::endl;
        sf::Sleep(0.5f);
    }

    return 0;
}

It compiles fine. But when I try to run, I get a segmentation fault upon the declaration(calling of the constructor, actually) of  sf::Clock Clock.

Am I missing something?
Thanks!

Celtic Minstrel

  • Jr. Member
  • **
  • Posts: 80
    • View Profile
Um... if you're using a static version, why do you have dlls...?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
You probably need to recompile SFML. But you should use SFML 2.0, there's a precompiled RC available.

And yes, the libraries that you link to are the dynamic ones, the static ones have the -s suffix.
Laurent Gomila - SFML developer

Midleiro F

  • Newbie
  • *
  • Posts: 14
    • View Profile
Okay, yeah, I meant to write that I was linking dinamically, sorry.

I tried linking with the precompiled 2.0 version, both SJLJ and DW2(just in case) and neither worked, the problem was the same.

Could help me out? I'm trying to build it now with CMake, but it says I'm missling libgmp-10.dll. I already put my MinGW/bin directory in the path, and that dll IS in the .bin folder.
I'm getting the following errors:
Quote
CMake Error at cmake/Config.cmake:62 (message):
  Unsupported compiler
Call Stack (most recent call first):
  CMakeLists.txt:20 (include)

Also it shows something called CMAKE_CODEBLOCKS_EXECUTABLE with value CMAKE_CODEBLOCKS_EXECUTABLE-NOTFOUND.

Any thoughts?
Thanks!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Don't generate Code::Blocks projects, MinGW makefiles are enough for compiling SFML.

Many users have had problems with gcc 4.7 lately, you should try to find and read the related threads on the forum.
Laurent Gomila - SFML developer

Silvah

  • Guest
You probably need to recompile SFML.
Actually, the OP certainly does have to recompile SFML (and all other third-party C++ libraries), for the reasons explained before.

Midleiro F

  • Newbie
  • *
  • Posts: 14
    • View Profile
Problem was solved.

The problem really was with gcc 4.7. I uninstalled it and installed 4.61 and everything worked like a charm!

Thank you so much!