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

Author Topic: SFML/Audio: Music::Music() undefined reference?  (Read 2917 times)

0 Members and 1 Guest are viewing this topic.

DecoratorFawn82

  • Newbie
  • *
  • Posts: 10
    • View Profile
SFML/Audio: Music::Music() undefined reference?
« on: January 27, 2014, 04:43:22 pm »
Hi! I've tried to use the SFML/Audio class. But when I create an object for example:

Code: [Select]
    sf::Music mus;
    mus.openFromFile("music.wav");
    mus.play();

And try to use it. It gives me undefined reference. Even to the constructor?!
Well, this is the full code if it is anything wrong with it:

Code: [Select]
#include <iostream>
#include "SFML/Window.hpp"
#include "SFML/Graphics.hpp"
#include "SFML/Audio.hpp"

using namespace std;

int main()
{
    sf::RenderWindow window(sf::VideoMode(640, 480), "Window");
    sf::Event event;
    sf::Music mus;
    mus.openFromFile("music.wav");
    mus.play();
    while (window.isOpen())
    {
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
            {
                window.close();
            }
        }
        window.clear(sf::Color::Black);
        window.display();
    }
    return 0;
}

Isn't it enough with just including these lines?:
Code: [Select]
#include "SFML/Window.hpp"
#include "SFML/Graphics.hpp"
#include "SFML/Audio.hpp"

Or do I have to include even more directiories?
The bunch of errors I'm getting is undefined reference
to everything. This is how it looks like:

EDITED:
Couldn't get an image of it to the forum :(

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: SFML/Audio: Music::Music() undefined reference?
« Reply #1 on: January 27, 2014, 04:46:09 pm »
Do you link to sfml-audio in your linker settings?
Laurent Gomila - SFML developer

DecoratorFawn82

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: SFML/Audio: Music::Music() undefined reference?
« Reply #2 on: January 27, 2014, 05:35:17 pm »
No I didn't :). Thank you!

I hadn't a thought of that until you said it. I can finally use the SFML/Audio class! :)