SFML setup errors

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Xillez
    New Member
    • Jul 2013
    • 93

    SFML setup errors

    Hey I'm trying to set up SFML but I get a couple errors:

    Editor: Code::blocks

    ||=== Build: Release in SFML_test (compiler: GNU GCC Compiler) ===|
    D:\SFML\lib\lib sfml-graphics-s.a(CircleShape .cpp.obj):Circl eShape.cpp|| undefined reference to `_Unwind_Resume '|
    D:\SFML\lib\lib sfml-graphics-s.a(CircleShape .cpp.obj):Circl eShape.cpp:(.te xt$_ZN2sf11Circ leShapeD0Ev[__ZN2sf11Circle ShapeD0Ev]+0x24)||undefin ed reference to `operator delete(void*, unsigned int)'|
    ||error: ld returned 1 exit status|
    ||=== Build failed: 3 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

    What is causing this?

    Thanks in advance :-)

    Compiler settings:





    Code:
    main.cpp:
    
    #include <SFML/Graphics.hpp>
    
    int main()
    {
        sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
        sf::CircleShape shape(100.f);
        shape.setFillColor(sf::Color::Green);
    
        while (window.isOpen())
        {
            sf::Event event;
            while (window.pollEvent(event))
            {
                if (event.type == sf::Event::Closed)
                    window.close();
            }
    
            window.clear();
            window.draw(shape);
            window.display();
        }
    
        return 0;
    }
  • hpmachining
    New Member
    • Oct 2015
    • 15

    #2
    It looks like you may be using a different version of MinGW gcc than SFML was built with. The "undefined reference to `_Unwind_Resume '" linker errors happen when mixing SJLJ and DW2 exception handling methods. Check this page to make sure you get the exact compiler and SFML versions:

    Right below the SFML downloads are links to the MinGW compilers that were used for the libraries. Or you can build SFML from source with your current compiler.

    You also may need to add more libraries to the list for a static build. I don't have CodeBlocks, but in Visual Studio 2013 I needed to add opengl32, jpeg, and winmm to the list for your code to build. See this link for others that may be needed when static linking:

    Look for the chart that shows "Modules" and "Dependenci es".

    Comment

    • Xillez
      New Member
      • Jul 2013
      • 93

      #3
      At: http://www.sfml-dev.org/tutorials/2.4/start-cb.php

      Under "Installing SFML": it says this:

      "If you are unsure, check which of the libgcc_s_sjlj-1.dll or libgcc_s_dw2-1.dll files is present in your MinGW/bin folder. If MinGW was installed along with Code::Blocks, you probably have an SJLJ version. "

      This is what I have in MinGW/Bin:


      If I only should have one version on installation with code::blocks, why do I have 2 versions now? and if I need to delete one, which one should I delete?

      Comment

      • hpmachining
        New Member
        • Oct 2015
        • 15

        #4
        I don't know why you have both. I would suggest you download the appropriate version that matches the SFML version you downloaded, and either rename your old MinGW directory to MinGW.backup, or whatever you want, then install the version that matches SFML, or you can install the new MinGW to a directory with a different name, such as MinGW-SFML and configure CodeBlocks to use it instead of the original.

        Comment

        • Xillez
          New Member
          • Jul 2013
          • 93

          #5
          This is a fresh new install of 32-bit gcc minGW via "Install On Demand" via a link from SFML's download site. And guess what I found:



          It installed both, and again I got the same errors.

          Comment

          • hpmachining
            New Member
            • Oct 2015
            • 15

            #6
            Ok, I confirmed that this version of SFML:
            SFML 2.4.0 GCC 4.9.2 TDM (SJLJ) - 32-bit

            works with the gcc that is installed in CodeBlocks at this link:
            codeblocks-16.01mingw-setup.exe

            When I installed CodeBlocks from that link, I also had both versions of the libraries in the MinGW directory, but as long as I built against the SFML version in the link I provided it worked. I only get the errors you get when trying to use the SFML library at this link:
            SFML 2.4.0 GCC 6.1.0 MinGW (DW2) - 32-bit
            If you want to use this SFML version, you need to download this compiler:
            MinGW Builds 6.1.0 (32-bit)
            You just need to extract it to a directory of your choosing. Then add the compiler to CodeBlocks. Probably the easiest way is to go to Settings->Compiler and copy the original gcc compiler profile, give the copy a new name, and adjust the path and names in the Toolchain Executables tab. For reference, "Make program" mingw32-make.exe doesn't change, but "C compiler" is just gcc.exe, "C++ compiler" is g++.exe and "Linker for dynamic libs" is g++.exe (no mingw- prefix)

            You will also need to add opengl32, jpeg, winmm and gdi32 to the linker settings to build the example.

            Comment

            • Xillez
              New Member
              • Jul 2013
              • 93

              #7
              Ok, it ran but it crashes on start:



              I added: opengl32, jpeg, winmm and gdi32 at the end of the linker settigs and switchd back to the codeblocks MinGW compiler

              Any Ideas?

              Comment

              • Xillez
                New Member
                • Jul 2013
                • 93

                #8
                It works now.
                After debugging it said it quit on startup with debugger code 740

                After searching the error code up I found it had to do with admin rights. I started Code Blocks with admin rights and it ran beautifully.

                Thanks for all the help :-)

                Comment

                • hpmachining
                  New Member
                  • Oct 2015
                  • 15

                  #9
                  You're welcome. I'm not sure why you have to run CodeBlocks with administrator rights, though. Can you run the program by double clicking it from the file explorer in Windows? Just curious.

                  Comment

                  • Xillez
                    New Member
                    • Jul 2013
                    • 93

                    #10
                    Yes, I can. No problem at all.

                    It might be because code blocks needs admin rights to write something to the executable or maybe it is the connection between my program and the debug program managers of code blocks...

                    I don't know but it works XD

                    Comment

                    Working...