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?
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" (http://nightlybuilds.ch/compiler/show/12/MinGW-builds-490r2-32/)).
It's also helpful if you provide the full build command (http://en.sfml-dev.org/forums/index.php?topic=12552.0).
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
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.