SFML community forums

Help => Audio => Topic started by: Gregory on October 17, 2013, 06:41:29 am

Title: sf::SoundStream linking error?
Post by: Gregory on October 17, 2013, 06:41:29 am
Hello guys.

The sf::SoundStream appears to show a linking error with sf::Thread

This is the code I am trying to compile:

audioStream.hpp:
#pragma once

#include <string>
#include <SFML/System.hpp>
#include <SFML/Audio.hpp>

class audioStream : public sf::SoundStream {
    public:
        void setFile(std::string file);
        bool startLoading();
        bool isLoaded();
        audioStream();


    private:
        void load();
        bool onGetData(Chunk& chunk);
        void onSeek(unsigned int timeOffset);

    sf::SoundBuffer buffer;

    std::string m_file;
    bool m_loaded;
    sf::Thread *m_loadThread;
    sf::Mutex m_loadMutex;

    int streamPosition;
    int fileSize;

};

 

audioStream.cpp:
#include "audioStream.hpp"

bool audioStream::onGetData(Chunk& chunk) {
    return 0;
}

void audioStream::onSeek(unsigned int timeOffset) {}

audioStream::audioStream() {}
 

Build Messages:
C:\SFML-2.1\lib\libsfml-audio-s-d.a(SoundStream.cpp.obj)||In function `ZN2sf11SoundStreamD2Ev':|
D:\downloads\SFML-2.1\src\SFML\Audio\SoundStream.cpp|56|undefined reference to `sf::Thread::~Thread()'|
D:\downloads\SFML-2.1\src\SFML\Audio\SoundStream.cpp|56|undefined reference to `sf::Thread::~Thread()'|
C:\SFML-2.1\lib\libsfml-audio-s-d.a(SoundStream.cpp.obj)||In function `ZN2sf11SoundStream4playEv':|
D:\downloads\SFML-2.1\src\SFML\Audio\SoundStream.cpp|105|undefined reference to `sf::Thread::launch()'|
C:\SFML-2.1\lib\libsfml-audio-s-d.a(SoundStream.cpp.obj)||In function `ZN2sf11SoundStream4stopEv':|
D:\downloads\SFML-2.1\src\SFML\Audio\SoundStream.cpp|121|undefined reference to `sf::Thread::wait()'|
C:\SFML-2.1\lib\libsfml-audio-s-d.a(SoundStream.cpp.obj)||In function `ZN2sf11SoundStream16setPlayingOffsetENS_4TimeE':|
D:\downloads\SFML-2.1\src\SFML\Audio\SoundStream.cpp|164|undefined reference to `sf::Thread::launch()'|
||=== Build finished: 5 errors, 0 warnings (0 minutes, 0 seconds) ===|
 

Thanks!
Title: Re: sf::SoundStream linking error?
Post by: Laurent on October 17, 2013, 08:02:54 am
Do you link to sfml-system?
Title: Re: sf::SoundStream linking error?
Post by: binary1248 on October 17, 2013, 10:38:31 am
If, and only if, you happen to still have undefined references after that, you can refer to this: http://en.sfml-dev.org/forums/index.php?topic=13242.msg93105#msg93105
Title: Re: sf::SoundStream linking error?
Post by: Gregory on October 18, 2013, 06:49:44 pm
Problem resolved. I was linking but the linking order was wrong.

Thanks