Optional parameter to signal "MousePressed"
« on: 28 January 2015, 09:54:37 »
Quote
obj/Handler.o: In function `ZN4tgui12extractTypesIIN2sf7Vector2IfEEEE6getRowEv':

D:/Programare/Libs/TGUI/include/TGUI/Signal.hpp:71: undefined reference to `std::string tgui::convertTypeToString<sf::Vector2<float> >()'
collect2.exe: error: ld returned 1 exit status

From what I read on the 0.7-dev documentation the signal "MousePressed" can have an optional parameter sf::Vector2f position, but I don't know how to use it because I'm receiving the above error from using this code:
Code: [Select]
m_windowTiles->connect("MousePressed", [this](sf::Vector2f position){ m_map->removeLastTile(); });

*

texus

  • *****
  • 1143
    • View Profile
    • Texus's Blog
Re: Optional parameter to signal "MousePressed"
« Reply #1 on: 28 January 2015, 10:53:54 »
In a simple piece of code that I used, the following works fine:
button->connect("MousePressed", [](sf::Vector2f position){});

What compiler are u using?

Re: Optional parameter to signal "MousePressed"
« Reply #2 on: 02 February 2015, 12:17:38 »
I have tried using mingw-w64 4.8.2 (i686-4.8.2-posix-dwarf-rt_v3-rev3) and mingw-w64 4.9.1 (i686-4.9.1-posix-dwarf-rt_v3-rev2) but same error.

*

texus

  • *****
  • 1143
    • View Profile
    • Texus's Blog
Re: Optional parameter to signal "MousePressed"
« Reply #3 on: 02 February 2015, 12:38:49 »
You get the same error when you use this instead of your line?
button->connect("MousePressed", [](sf::Vector2f position){});

What about this one? (it would give an error on runtime, but it is just to check if it compiles)
button->connect("MousePressed", [](int i){});

And what if you put this somewhere in your code?
template <> std::string convertTypeToString<sf::Vector2f>() { return "sf::Vector2f"; };

Re: Optional parameter to signal "MousePressed"
« Reply #4 on: 02 February 2015, 13:15:29 »
For the first line I received same errors.

For the second I receive:
Quote
obj/Handler.o: In function `ZN4tgui12extractTypesIIiEE6getRowEv':
D:/Programare/Libs/TGUI/include/TGUI/Signal.hpp:71: undefined reference to `std::string tgui::convertTypeToString<int>()'
collect2.exe: error: ld returned 1 exit status

And for the last one I putted like this out of my class:
Code: [Select]
namespace tgui
{
template <> inline std::string convertTypeToString<sf::Vector2f>() { return "sf::Vector2f"; };
}
And worked. Thanks for the workaround fix.

*

texus

  • *****
  • 1143
    • View Profile
    • Texus's Blog
Re: Optional parameter to signal "MousePressed"
« Reply #5 on: 02 February 2015, 13:27:58 »
It seems like the functions in Signal.cpp are not marked for being exported. Which is why it works on everywhere except on windows when using dlls.

It should be fixed in the latest version, but you can of course just keep using the workaround for now (as long as you delete that code when you ever update to a newer version).