undefined reference to `sf::String::operator
« on: 18 June 2017, 10:42:50 »
Hello, I have problem running example TGUI app.

Error:

/usr/lib/gcc/x86_64-pc-linux-gnu/7.1.1/../../../../lib/libtgui.so: undefined reference to `sf::String::operator std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >() const'
collect2: error: ld returned 1 exit status

I use g++ main.cpp -lsfml-graphics -lsfml-window -lsfml-system -ltgui -o test

*

texus

  • *****
  • 1172
    • View Profile
    • Texus's Blog
Re: undefined reference to `sf::String::operator
« Reply #1 on: 18 June 2017, 12:28:07 »
Did you just install SFML and TGUI or were they installed earlier and did you update your compiler since then?
Based on the error I would guess the latter and I would suggest compiling TGUI again.

Re: undefined reference to `sf::String::operator
« Reply #2 on: 18 June 2017, 17:24:03 »
I installed sfml and tgui using pacman/yaourt, they weren't preinstalled.

*

texus

  • *****
  • 1172
    • View Profile
    • Texus's Blog
Re: undefined reference to `sf::String::operator
« Reply #3 on: 18 June 2017, 17:27:50 »
That error shouldn't happen when you install TGUI from yaourt unless something happened afterwards.
If you e.g. do a system update with pacman then the gcc or SFML version may change and the TGUI libraries that you have installed may no longer be compatible (as they were installed with yaourt and thus not updated with the other packages).

So you should try removing TGUI and reinstalling it (with yaourt) and see if that fixes the issue.

Re: undefined reference to `sf::String::operator
« Reply #4 on: 18 June 2017, 18:03:05 »
Nothing happened :(
After reinstalling still the same error.

*

texus

  • *****
  • 1172
    • View Profile
    • Texus's Blog
Re: undefined reference to `sf::String::operator
« Reply #5 on: 18 June 2017, 18:21:20 »
Maybe there is some inconsistency with the compiler used to build the sfml and tgui libraries. You could try building SFML from source as well (by installing "sfml-git" from the AUR instead of the "sfml" package).

Edit: I just reproduced it here, using "sfml-git" instead of "sfml" solves the issue.
« Last Edit: 18 June 2017, 18:31:45 by texus »

Re: undefined reference to `sf::String::operator
« Reply #6 on: 18 June 2017, 18:38:02 »
Thanks for help :)
"sfml" from pacman is version 2.4.2, and "sfml-git" is 2.4.0.
It works.

*

texus

  • *****
  • 1172
    • View Profile
    • Texus's Blog
Re: undefined reference to `sf::String::operator
« Reply #7 on: 18 June 2017, 18:51:38 »
Quote
"sfml" from pacman is version 2.4.2, and "sfml-git" is 2.4.0.
This is not correct. The sfml-git package (just like tgui-git) always builds the latest version, sfml-git is thus newer than sfml 2.4.2. The version number displayed on the AUR is confusingly the version of the last update to the PKGBUILD script. For instance, tgui-git used to still show version 0.7-alpha2 while it was already building tgui 0.7.3. But any package with "-git" at the end should build the very latest version, no matter what the version number on the AUR says.
« Last Edit: 18 June 2017, 19:26:30 by texus »