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

Author Topic: undefined reference to...  (Read 2572 times)

0 Members and 1 Guest are viewing this topic.

Bool_Wolf

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
undefined reference to...
« on: April 27, 2017, 08:16:41 pm »
Hi, I'm newbie, i recently downloaded the SFML 2.4.2 library and i tried to use it into a my own project.

I followed the official tutorial (https://www.sfml-dev.org/tutorials/2.4/start-cb.php), but i have a problem.

I used the static library version, so i linked the necessary lib (graphics, window and finally system), and i tried to build the project, Below the 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;
}
 

And now the output error:

||=== Build: Release in smfl snake (compiler: GNU GCC Compiler) ===|
C:\Users\User\SFML-2.4.2\lib\libsfml-graphics-s.a(CircleShape.cpp.obj):CircleShape.cpp|| undefined reference to `_Unwind_Resume'|
C:\Users\User\SFML-2.4.2\lib\libsfml-graphics-s.a(CircleShape.cpp.obj):CircleShape.cpp:(.text$_ZN2sf11CircleShapeD0Ev[__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), 5 second(s)) ===|

I have the suspicion that i don't include all necessary lib, but i dont't know what.

Anyone can help me?
Thanks.

P.S.: I use Code::Blocks, MinGW

Arcade

  • Full Member
  • ***
  • Posts: 230
    • View Profile
Re: undefined reference to...
« Reply #1 on: April 27, 2017, 08:35:52 pm »
Are you 100% sure you downloaded the version of SFML that matches your compiler? Be sure to read everything in that tutorial link you provided (especially the things in the red boxes).

Bool_Wolf

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Re: undefined reference to...
« Reply #2 on: April 27, 2017, 08:45:40 pm »
Yes, i followed every step carefully.
I try to change the version library now, an i hope it is a problem of version.

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: undefined reference to...
« Reply #3 on: April 27, 2017, 10:04:16 pm »
Did you define "SFML_STATIC"?

i linked the necessary lib (graphics, window and finally system)
Those modules also have dependancies that also need linking when building statically.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Bool_Wolf

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Re: undefined reference to...
« Reply #4 on: April 28, 2017, 03:56:11 pm »
Yes, I defined this macro, and i have also linked the other libraries.
Here the list (in the right order):

sfml-graphics-s
freetype
jpeg
sfml-window-s
opengl32
gdi32
sfml-audio-s
openal32
flac
vorbisenc
vorbisfile
vorbis
ogg
sfml-network-s
ws2_32
sfml-system-s
winmm

I have add this libraries not into the "Debug" or the "Release" voice, but only into the general build options. I've done rightly?

obviously i also insert the search directories paths (include and lib).

So what doesn't work!?
« Last Edit: April 28, 2017, 03:58:28 pm by Bool_Wolf »

 

anything