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

Author Topic: Undefined reference to 'sf::Music::Music()'  (Read 2958 times)

0 Members and 1 Guest are viewing this topic.

rtm5

  • Newbie
  • *
  • Posts: 4
    • View Profile
Undefined reference to 'sf::Music::Music()'
« on: October 04, 2015, 10:40:46 pm »
Hi All,

I am very new to programming, and I am attempting to create a simple audio player. I am getting an error message when I try and compile the following code:

#include <SFML/Audio/Music.hpp>

int main(int argc, char* argv[])
{
     sf::Music music;
     
      return 0;
}


I'm compiling like so:

g++ main.cpp -o main

Here is the error message:

/tmp/ccOEn1HF.o: In function `main':
main.cpp:(.text+0x24): undefined reference to `sf::Music::Music()'
main.cpp:(.text+0x38): undefined reference to `sf::Music::~Music()'
collect2: error: ld returned 1 exit status

Not sure what the problem is!?

G.

  • Hero Member
  • *****
  • Posts: 1593
    • View Profile
Re: Undefined reference to 'sf::Music::Music()'
« Reply #1 on: October 04, 2015, 10:45:54 pm »
You have to link the SFML modules you're using. (audio and system)
Take a (good) look at this FAQ and this tutorial.

rtm5

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Undefined reference to 'sf::Music::Music()'
« Reply #2 on: October 05, 2015, 01:10:39 am »
Thanks for the helpful links, I got it working!

 

anything