By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,950 Members | 989 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,950 IT Pros & Developers. It's quick & easy.

SFML setup errors

P: 88
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\libsfml-graphics-s.a(CircleShape.cpp.obj):CircleShape.cpp|| undefined reference to `_Unwind_Resume'|
D:\SFML\lib\libsfml-graphics-s.a(CircleShape.cpp.obj):CircleShape.cpp:(.text$_Z N2sf11CircleShapeD0Ev[__ZN2sf11CircleShapeD0Ev]+0x24)||undefined 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:
http://imgur.com/2LFGKrt
http://imgur.com/OHbg298
http://imgur.com/7y0oHt3
http://imgur.com/NWcl3Fm

Expand|Select|Wrap|Line Numbers
  1. main.cpp:
  2.  
  3. #include <SFML/Graphics.hpp>
  4.  
  5. int main()
  6. {
  7.     sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
  8.     sf::CircleShape shape(100.f);
  9.     shape.setFillColor(sf::Color::Green);
  10.  
  11.     while (window.isOpen())
  12.     {
  13.         sf::Event event;
  14.         while (window.pollEvent(event))
  15.         {
  16.             if (event.type == sf::Event::Closed)
  17.                 window.close();
  18.         }
  19.  
  20.         window.clear();
  21.         window.draw(shape);
  22.         window.display();
  23.     }
  24.  
  25.     return 0;
  26. }
  27.  
  28.  
Sep 11 '16 #1

✓ answered by hpmachining

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.

Share this Question
Share on Google+
9 Replies


P: 15
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:
http://www.sfml-dev.org/download/sfml/2.4.0/
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:
http://www.sfml-dev.org/tutorials/2.4/start-cb.php
Look for the chart that shows "Modules" and "Dependencies".
Sep 13 '16 #2

P: 88
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:
http://imgur.com/QV7fz62

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?
Sep 14 '16 #3

P: 15
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.
Sep 15 '16 #4

P: 88
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:

http://imgur.com/a/DIYwF

It installed both, and again I got the same errors.
Sep 19 '16 #5

P: 15
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.
Sep 19 '16 #6

P: 88
Ok, it ran but it crashes on start:

http://imgur.com/a/JAD8T

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

Any Ideas?
Sep 20 '16 #7

P: 88
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 :-)
Sep 20 '16 #8

P: 15
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.
Sep 20 '16 #9

P: 88
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
Sep 22 '16 #10

Post your reply

Sign in to post your reply or Sign up for a free account.