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

Author Topic: Eclipse: undefined reference  (Read 8638 times)

0 Members and 1 Guest are viewing this topic.

c-jay

  • Newbie
  • *
  • Posts: 26
    • View Profile
    • Email
Eclipse: undefined reference
« on: August 10, 2016, 07:51:48 pm »
Hi,

after updating ubuntu to 16.04 xenial and sfml cmake + make and csfml cmake + make i get the following failure in Eclipse

 Nicht definierter Verweis auf == undefined reference to
19:41:37 **** Incremental Build of configuration Debug for project TEST ****
make all
Building target: TEST
Invoking: Cross GCC Linker
gcc -L/home/user/Programme/SFML_build/lib -o "TEST"  ./src/dir.o ./src/gen_tfs.o ./src/iname.o ./src/init_tfs.o ./src/inode.o ./src/main.o ./src/read_from_fs.o ./src/sf_Inodes.o ./src/sf_buttons.o ./src/sf_functions.o ./src/sfml.o ./src/spec_tfs.o ./src/utils.o ./src/write_to_fs.o   -lcsfml-graphics -lpthread -lcsfml-system -lcsfml-window
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libcsfml-graphics.so: Nicht definierter Verweis auf `sf::Texture::loadFromFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, sf::Rect<int> const&)'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libcsfml-graphics.so: Nicht definierter Verweis auf `sf::Shader::loadFromFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, sf::Shader::Type)'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libcsfml-graphics.so: Nicht definierter Verweis auf `sf::Shader::setParameter(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, float)'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libcsfml-graphics.so: Nicht definierter Verweis auf `sf::Shader::setParameter(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, sf::Vector2<float> const&)'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libcsfml-graphics.so: Nicht definierter Verweis auf `sf::Shader::setParameter(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, float, float, float, float)'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libcsfml-graphics.so: Nicht definierter Verweis auf `sf::Shader::loadFromMemory(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, sf::Shader::Type)'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libcsfml-graphics.so: Nicht definierter Verweis auf `sf::Shader::setParameter(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, sf::Texture const&)'
makefile:30: die Regel für Ziel "TEST" scheiterte
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libcsfml-graphics.so: Nicht definierter Verweis auf `sf::Shader::loadFromFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libcsfml-graphics.so: Nicht definierter Verweis auf `sf::Shader::setParameter(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, sf::Vector3<float> const&)'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libcsfml-graphics.so: Nicht definierter Verweis auf `sf::Font::loadFromFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libcsfml-graphics.so: Nicht definierter Verweis auf `sf::Shader::setParameter(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, float, float)'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libcsfml-graphics.so: Nicht definierter Verweis auf `sf::Font::getGlyph(unsigned int, unsigned int, bool) const'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libcsfml-graphics.so: Nicht definierter Verweis auf `sf::Image::saveToFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libcsfml-window.so: Nicht definierter Verweis auf `sf::String::operator std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >[abi:cxx11]() const'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libcsfml-graphics.so: Nicht definierter Verweis auf `sf::Shader::setParameter(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, sf::Shader::CurrentTextureType)'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libcsfml-graphics.so: Nicht definierter Verweis auf `sf::Shader::setParameter(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, sf::Color const&)'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libcsfml-graphics.so: Nicht definierter Verweis auf `sf::Shader::setParameter(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, sf::Transform const&)'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libcsfml-graphics.so: Nicht definierter Verweis auf `sf::Shader::setParameter(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, float, float, float)'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libcsfml-graphics.so: Nicht definierter Verweis auf `sf::String::toAnsiString[abi:cxx11](std::locale const&) const'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libcsfml-graphics.so: Nicht definierter Verweis auf `sf::Shader::loadFromMemory(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libcsfml-graphics.so: Nicht definierter Verweis auf `sf::Image::loadFromFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
collect2: error: ld returned 1 exit status
make: *** [TEST] Fehler 1

i'm very thankful for every solution

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10936
    • View Profile
    • development blog
    • Email
Re: Eclipse: undefined reference
« Reply #1 on: August 10, 2016, 08:46:44 pm »
If you didn't link SFML statically against CSFML, you'll have to link SFML as well.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

c-jay

  • Newbie
  • *
  • Posts: 26
    • View Profile
    • Email
Re: Eclipse: undefined reference
« Reply #2 on: August 10, 2016, 09:02:28 pm »
How could i link SFML statically against CSFML with Eclipse? Or how could I link SFML with eclipse?

I added sfml-graphics, sfml-system and sfml-window to settings->linker->libraries and now the console output of eclipse changed to:

Building target: TEST
Invoking: Cross GCC Linker
g++ -L/home/user/Programme/SFML_build/lib -o "TEST"  ./src/dir.o ./src/gen_tfs.o ./src/iname.o ./src/init_tfs.o ./src/inode.o ./src/main.o ./src/read_from_fs.o ./src/sf_Inodes.o ./src/sf_buttons.o ./src/sf_functions.o ./src/sfml.o ./src/spec_tfs.o ./src/utils.o ./src/write_to_fs.o   -lsfml-graphics -lsfml-system -lsfml-window -lcsfml-graphics -lcsfml-system -lcsfml-window
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libcsfml-graphics.so: Nicht definierter Verweis auf `sf::Font::getGlyph(unsigned int, unsigned int, bool) const'
/home/christian/Programme/SFML_build/lib/libsfml-graphics.so: Nicht definierter Verweis auf `__cpu_model'
collect2: error: ld returned 1 exit status
make: *** [TEST] Fehler 1
makefile:30: die Regel für Ziel "TEST" scheiterte

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10936
    • View Profile
    • development blog
    • Email
Re: Eclipse: undefined reference
« Reply #3 on: August 10, 2016, 09:21:47 pm »
This is currently a bug in GCC on Ubuntu. See this thread.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

c-jay

  • Newbie
  • *
  • Posts: 26
    • View Profile
    • Email
Re: Eclipse: undefined reference
« Reply #4 on: August 10, 2016, 09:36:45 pm »
thank you. But I don't understand the solution. How could I add -lgcc_s -lgcc at the end of the g++ command that links the shared library?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10936
    • View Profile
    • development blog
    • Email
Re: Eclipse: undefined reference
« Reply #5 on: August 10, 2016, 09:57:13 pm »
The solution is to apply the patch from the link and rebuild SFML.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

c-jay

  • Newbie
  • *
  • Posts: 26
    • View Profile
    • Email
Re: Eclipse: undefined reference
« Reply #6 on: August 10, 2016, 10:03:43 pm »
okay my mistake. i read it again and took the workaround. After this the last error is the following:


21:59:41 **** Incremental Build of configuration Debug for project TEST ****
make all
Building target: TEST
Invoking: Cross GCC Linker
g++ -L/home/user/Programme/SFML_build/lib -o "TEST"  ./src/dir.o ./src/gen_tfs.o ./src/iname.o ./src/init_tfs.o ./src/inode.o ./src/main.o ./src/read_from_fs.o ./src/sf_Inodes.o ./src/sf_buttons.o ./src/sf_functions.o ./src/sfml.o ./src/spec_tfs.o ./src/utils.o ./src/write_to_fs.o   -lsfml-graphics -lsfml-window -lcsfml-graphics -lcsfml-system -lcsfml-window -lsfml-system -lgcc_s -lgcc
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libcsfml-graphics.so: Nicht definierter Verweis auf `sf::Font::getGlyph(unsigned int, unsigned int, bool) const'
collect2: error: ld returned 1 exit status
makefile:30: die Regel für Ziel "TEST" scheiterte
make: *** [TextFS] Fehler 1

Any solution?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10936
    • View Profile
    • development blog
    • Email
Re: Eclipse: undefined reference
« Reply #7 on: August 10, 2016, 10:57:37 pm »
Since CSFML depends on SFML, the SFML libs need to be listed after the CSFML libs (e.g. -lcsfml-graphics ... -lsfml-graphics).
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

c-jay

  • Newbie
  • *
  • Posts: 26
    • View Profile
    • Email
Re: Eclipse: undefined reference
« Reply #8 on: August 11, 2016, 05:57:25 pm »
Hm i tried both. First csfml and first sfml libs

Building target: TEST
Invoking: Cross GCC Linker
g++ -L/home/user/Programme/SFML_build/lib -o "TEST"  ./src/dir.o ./src/gen_tfs.o ./src/iname.o ./src/init_tfs.o ./src/inode.o ./src/main.o ./src/read_from_fs.o ./src/sf_Inodes.o ./src/sf_buttons.o ./src/sf_functions.o ./src/sfml.o ./src/spec_tfs.o ./src/utils.o ./src/write_to_fs.o   -lcsfml-graphics -lsfml-graphics -lcsfml-window -lsfml-window -lcsfml-system -lsfml-system -lgcc_s -lgcc
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libcsfml-graphics.so: Nicht definierter Verweis auf `sf::Font::getGlyph(unsigned int, unsigned int, bool) const'
collect2: error: ld returned 1 exit status
makefile:30: die Regel für Ziel "TEST" scheiterte
make: *** [TEST] Fehler 1

... but the failure is the same.

Any other idea?

c-jay

  • Newbie
  • *
  • Posts: 26
    • View Profile
    • Email
Re: Eclipse: undefined reference
« Reply #9 on: August 11, 2016, 07:05:57 pm »
Adding CSFML Library search path and SFML include path solved my problem. Thank you very much for your support eXpl0it3r!!

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10936
    • View Profile
    • development blog
    • Email
Re: Eclipse: undefined reference
« Reply #10 on: August 11, 2016, 09:09:15 pm »
The proper order would be:

-lcsfml-graphics -lcsfml-window -lcsfml-system -lsfml-graphics -lsfml-window -lsfml-system
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything