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

Author Topic: Undefined Reference To thor::Action::Action(sf::Event::EventType)  (Read 4478 times)

0 Members and 1 Guest are viewing this topic.

Xilen

  • Newbie
  • *
  • Posts: 14
    • View Profile
Hi there,
(I'm not sure if this topic belongs here or if I should contact the Thor dev directly)
I've built SFML using cmake and MinGW 4.8.1 and I'm using the latest nightly build of Thor but it crashes. I've read the documentation on it and I've searched the forums but no one seems to have the same problem as I do.

Here's the code
#include <iostream>
#include "SFML/Graphics.hpp"
#include "SFML/System.hpp"
#include "Thor/Input.hpp"

int main()
{
        thor::Action c(sf::Event::Closed);
        thor::ActionMap<std::string> map;
        map["exit"] = c;

        sf::RenderWindow window(sf::VideoMode(640,480,32), "Hello", sf::Style::Close | sf::Style::Titlebar);

        while (window.isOpen())
        {
                map.update(window);
                if (map.isActive("exit"))
                        window.close();

                window.display();
        }

}
 

And here's the entire error:
C:\Users\Xilen\AppData\Local\Temp\ccVwUy6F.o:main.cpp:(.text+0xe4): undefined reference to `thor::Action::Action(sf::Event::EventType)'
C:\Users\Xilen\AppData\Local\Temp\ccVwUy6F.o:main.cpp:(.text$_ZN4thor9ActionMap
ISsEC1Ev[__ZN4thor9ActionMapISsEC1Ev]+0x63): undefined reference to `thor::detail::EventBuffer::EventBuffer()'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: C:\Users\Xilen\AppData\Local\Temp\ccVwUy6F.o: bad reloc address 0x63 in section `.text$_Z
N4thor9ActionMapISsEC1Ev[__ZN4thor9ActionMapISsEC1Ev]'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: final link
 failed: Invalid operation
collect2.exe: error: ld returned 1 exit status
 

Is there a MinGW command line arg that I have to use to get it working?
« Last Edit: July 10, 2014, 02:07:27 pm by Xilen »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10821
    • View Profile
    • development blog
    • Email
Re: Undefined Reference To thor::Action::Action(sf::Event::EventType)
« Reply #1 on: July 10, 2014, 02:19:44 pm »
If you grabbed my latest Nightly Build of Thor, you should probably also grab the latest SFML Nightly Build, then usually get always compiled at the same time and thus guarantee to work.

Where did you get your MinGW version from? Because currently I've only TDM builds with the version 4.8.1. Personally I'd advice you to grab the MinGW Builds compiler which is at version 4.9.0 (see "Download Compiler").

It's also helpful if you provide the full build command.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Undefined Reference To thor::Action::Action(sf::Event::EventType)
« Reply #2 on: July 10, 2014, 02:32:39 pm »
It crashes? That's a linker error.

How have you linked Thor?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Xilen

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Undefined Reference To thor::Action::Action(sf::Event::EventType)
« Reply #3 on: July 10, 2014, 02:39:15 pm »
If you grabbed my latest Nightly Build of Thor, you should probably also grab the latest SFML Nightly Build, then usually get always compiled at the same time and thus guarantee to work.

Where did you get your MinGW version from? Because currently I've only TDM builds with the version 4.8.1. Personally I'd advice you to grab the MinGW Builds compiler which is at version 4.9.0 (see "Download Compiler").

It's also helpful if you provide the full build command.

Ok, I downloaded the nightly builds of both but still no luck. I then downloaded MinGW 4.9 and then this happened
../main.cpp:1:20: fatal error: iostream: No such file or directory
 #include <iostream>
I'm going to completely reinstall MinGW and hopefully that will fix it.

As for the linking, I have no idea what you mean, I installed the library the same way I do everything else; put all the files in the mingw folder.

Here's my command line
g++ ../main.cpp -o output.exe -std=c++11 -DSFML_STATIC -lsfml-graphics -lsfml-window -lsfml-system

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10821
    • View Profile
    • development blog
    • Email
Re: Undefined Reference To thor::Action::Action(sf::Event::EventType)
« Reply #4 on: July 10, 2014, 02:41:09 pm »
Well you defined SFML_STATIC and yet you link the dynamic libraries. and not link Thor at all...
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Undefined Reference To thor::Action::Action(sf::Event::EventType)
« Reply #5 on: July 10, 2014, 02:53:52 pm »
As for the linking, I have no idea what you mean, I installed the library the same way I do everything else
No, you forgot to link Thor. See here.
Checking whether libraries are linked correctly is the absolutely first thing you should do whenever you have an "undefined reference to" error.

Quote
put all the files in the mingw folder.
That's not how you should do it. Choose a separate directory with your C++ libraries, and specify its path to the linker.
« Last Edit: July 10, 2014, 02:55:44 pm by Nexus »
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Xilen

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Undefined Reference To thor::Action::Action(sf::Event::EventType)
« Reply #6 on: July 10, 2014, 03:51:54 pm »
Ok, I got it linked but it throws a new error (another undefined reference but this time it's all kinds of weird)
C:\Users\Xilen\AppData\Local\Temp\ccPIt8f4.o:main.cpp:(.text+0xa0): undefined reference to `_imp___ZN4thor6ActionC1EN2sf5Event9EventTypeE'
C:\Users\Xilen\AppData\Local\Temp\ccPIt8f4.o:main.cpp:(.text$_ZN4thor9ActionMap
ISsEC1Ev[__ZN4thor9ActionMapISsEC1Ev]+0x27): undefined reference to `_imp___ZN4t
hor6detail11EventBufferC1Ev'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: C:\Users\Xilen\AppData\Local\Temp\ccPIt8f4.o: bad reloc address 0x27 in section `.text$_Z
N4thor9ActionMapISsEC1Ev[__ZN4thor9ActionMapISsEC1Ev]'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: final link
 failed: Invalid operation
collect2.exe: error: ld returned 1 exit status
My new command line
g++ ../main.cpp -o thor.exe -static -std=c++11 -lsfml-graphics -lsfml-window -lsfml-system -lthor-s
I have to use "-lthor-s" because "ld.exe cannot find -lthor".
And "-static" is so that I don't get the "libgcc_s_sjlj-1.dll is missing from this computer" error.

I tried getting MinGW 4.9 but that just breaks all my includes.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10821
    • View Profile
    • development blog
    • Email
Re: Undefined Reference To thor::Action::Action(sf::Event::EventType)
« Reply #7 on: July 10, 2014, 03:55:46 pm »
You can just start mixing things however you like or because the linker couldn't find something... ::)

My advice is, EITHER build everything dynamic and link everything dynamic OR build everything static and link everything static. It's possible to use different combinations, but if you do so, you need to actually understand what they do etc.

As for you problem current setup, you need to define THOR_STATIC if you link Thor statically.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Undefined Reference To thor::Action::Action(sf::Event::EventType)
« Reply #8 on: July 10, 2014, 04:01:40 pm »
SFML and Thor must be linked both either statically or dynamically. There is no THOR_STATIC, Thor adopts SFML_STATIC since both are linked the same way.

And you should avoid -static unless you know exactly what you're doing (which is currently not the case). Also, bear in mind the library order.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10821
    • View Profile
    • development blog
    • Email
Re: Undefined Reference To thor::Action::Action(sf::Event::EventType)
« Reply #9 on: July 10, 2014, 04:08:31 pm »
SFML and Thor must be linked both either statically or dynamically. There is no THOR_STATIC, Thor adopts SFML_STATIC since both are linked the same way.
Ah okay, sorry had that mixed up. ;D

If you're trying to link statically and fail at it, you might want to read this, since static linking in SFML changed.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Xilen

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Undefined Reference To thor::Action::Action(sf::Event::EventType)
« Reply #10 on: July 10, 2014, 04:11:50 pm »
I was able to get it to compile (there we a couple warnings about macros) but it asks for libgcc_s_sjlj-1.dll which doesn't exist with MinGW32 4.8.1.