SFML community forums

Help => Audio => Topic started by: DecoratorFawn82 on January 27, 2014, 04:43:22 pm

Title: SFML/Audio: Music::Music() undefined reference?
Post by: DecoratorFawn82 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 :(
(http://C:\Users\Kevin\Desktop\IMG\code_fail.png)
Title: Re: SFML/Audio: Music::Music() undefined reference?
Post by: Laurent on January 27, 2014, 04:46:09 pm
Do you link to sfml-audio in your linker settings?
Title: Re: SFML/Audio: Music::Music() undefined reference?
Post by: DecoratorFawn82 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! :)