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

Author Topic: "Undefined reference to" error when I build my game.  (Read 5807 times)

0 Members and 1 Guest are viewing this topic.

SkeleDotCpp

  • Newbie
  • *
  • Posts: 12
    • View Profile
"Undefined reference to" error when I build my game.
« on: December 28, 2017, 09:44:29 pm »
When I run my game, I get these errors:
Quote
s Folder\CodeBlocks\SFML-2.4.2\lib\libsfml-audio-s.a(InputSoundFile.cpp.obj):InputSoundFile.cpp|| undefined reference to `sf::FileInputStream::FileInputStream()'|
s Folder\CodeBlocks\SFML-2.4.2\lib\libsfml-audio-s.a(InputSoundFile.cpp.obj):InputSoundFile.cpp|| undefined reference to `sf::FileInputStream::open(std::string const&)'|
s Folder\CodeBlocks\SFML-2.4.2\lib\libsfml-audio-s.a(InputSoundFile.cpp.obj):InputSoundFile.cpp|| undefined reference to `sf::MemoryInputStream::MemoryInputStream()'|
s Folder\CodeBlocks\SFML-2.4.2\lib\libsfml-audio-s.a(InputSoundFile.cpp.obj):InputSoundFile.cpp|| undefined reference to `sf::MemoryInputStream::open(void const*, unsigned int)'|
s Folder\CodeBlocks\SFML-2.4.2\lib\libsfml-audio-s.a(SoundFileFactory.cpp.obj):SoundFileFactory.cpp|| undefined reference to `sf::MemoryInputStream::MemoryInputStream()'|
s Folder\CodeBlocks\SFML-2.4.2\lib\libsfml-audio-s.a(SoundFileFactory.cpp.obj):SoundFileFactory.cpp|| undefined reference to `sf::MemoryInputStream::open(void const*, unsigned int)'|
s Folder\CodeBlocks\SFML-2.4.2\lib\libsfml-audio-s.a(SoundFileFactory.cpp.obj):SoundFileFactory.cpp|| undefined reference to `sf::MemoryInputStream::seek(long long)'|
s Folder\CodeBlocks\SFML-2.4.2\lib\libsfml-audio-s.a(SoundFileFactory.cpp.obj):SoundFileFactory.cpp|| undefined reference to `sf::FileInputStream::FileInputStream()'|
s Folder\CodeBlocks\SFML-2.4.2\lib\libsfml-audio-s.a(SoundFileFactory.cpp.obj):SoundFileFactory.cpp|| undefined reference to `sf::FileInputStream::open(std::string const&)'|
s Folder\CodeBlocks\SFML-2.4.2\lib\libsfml-audio-s.a(SoundFileFactory.cpp.obj):SoundFileFactory.cpp|| undefined reference to `sf::FileInputStream::seek(long long)'|
s Folder\CodeBlocks\SFML-2.4.2\lib\libsfml-audio-s.a(SoundFileFactory.cpp.obj):SoundFileFactory.cpp|| undefined reference to `sf::FileInputStream::~FileInputStream()'|

This is the code that causes this:
sf::SoundBuffer rifleShotBuffer;
if (!rifleShotBuffer.loadFromFile("Audio/RifleShot.wav")) {
   return EXIT_FAILURE;
}
 

Can someone explain why this happens?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11035
    • View Profile
    • development blog
    • Email
Re: "Undefined reference to" error when I build my game.
« Reply #1 on: December 29, 2017, 10:10:34 am »
Sounds like you didn't link the libraries in the right order. It should always be X depends on Y, the X needs to be specified before Y.
sfml-audio depends on sfml-system...
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

SkeleDotCpp

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: "Undefined reference to" error when I build my game.
« Reply #2 on: January 01, 2018, 07:43:54 pm »
This is how I linked my libraries:
Quote
sfml-graphics-s
(All dependencies for graphics)
sfml-window-s
(All dependencies for window)
sfml-system-s
(All dependencies for system)
sfml-audio-s
(All dependencies for audio)

Is this the right order?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11035
    • View Profile
    • development blog
    • Email
Re: "Undefined reference to" error when I build my game.
« Reply #3 on: January 01, 2018, 08:45:10 pm »
No, read again or read the official tutorial

Sounds like you didn't link the libraries in the right order. It should always be X depends on Y, the X needs to be specified before Y.
sfml-audio depends on sfml-system...
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

SkeleDotCpp

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: "Undefined reference to" error when I build my game.
« Reply #4 on: January 03, 2018, 09:12:22 pm »
I have re checked and fixed the issue with the order. Thank you :)

 

anything