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

Author Topic: undefined reference to `sf::SoundBuffer::SoundBuffer()'  (Read 8968 times)

0 Members and 1 Guest are viewing this topic.

Alfonso1

  • Newbie
  • *
  • Posts: 8
    • View Profile
undefined reference to `sf::SoundBuffer::SoundBuffer()'
« on: May 04, 2011, 08:29:01 pm »
I am using Windows XP and code::block

when I load some sample (for example the "sound" sample) and try to compile it, it geves me an error

undefined reference to `sf::SoundBuffer::SoundBuffer()'

what can i do?

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
undefined reference to `sf::SoundBuffer::SoundBuffer()'
« Reply #1 on: May 04, 2011, 09:05:00 pm »
Link the SFML libraries. But I have already told you that twice here.

Have you ever taken a look at the official tutorials? :roll:
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Alfonso1

  • Newbie
  • *
  • Posts: 8
    • View Profile
undefined reference to `sf::SoundBuffer::SoundBuffer()'
« Reply #2 on: May 04, 2011, 09:20:33 pm »
is these the official totorial?

Tutorial - Getting started - SFML and Code::Blocks (MinGW)
http://www.sfml-dev.org/tutorials/1.6/start-cb.php

yes I had read it, but I can't link the library

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
undefined reference to `sf::SoundBuffer::SoundBuffer()'
« Reply #3 on: May 04, 2011, 09:32:14 pm »
Quote from: "Alfonso1"
is these the official totorial?
Yes.

Quote from: "Alfonso1"
yes I had read it, but I can't link the library
If you tried at least to describe your problem in a meaningful way, we would be able to help you. But like this, it is really difficult. Why exactly can't you link the library? What doesn't work?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Alfonso1

  • Newbie
  • *
  • Posts: 8
    • View Profile
undefined reference to `sf::SoundBuffer::SoundBuffer()'
« Reply #4 on: May 05, 2011, 12:33:43 am »
I dont know, when I try to compile it gives me these error.

obj\Debug\main.o||In function `Z9PlaySoundv':|
C:\Documents and Settings\Administrador\Mis documentos\asd\Prueba\main.cpp|17|undefined reference to `_imp___ZN2sf11SoundBufferC1Ev'|
C:\Documents and Settings\Administrador\Mis documentos\asd\Prueba\main.cpp|18|undefined reference to `_imp___ZN2sf11SoundBuffer12LoadFromFileERKSs'|
C:\Documents and Settings\Administrador\Mis documentos\asd\Prueba\main.cpp|24|undefined reference to `_imp___ZNK2sf11SoundBuffer11GetDurationEv'|
C:\Documents and Settings\Administrador\Mis documentos\asd\Prueba\main.cpp|25|undefined reference to `_imp___ZNK2sf11SoundBuffer13GetSampleRateEv'|
C:\Documents and Settings\Administrador\Mis documentos\asd\Prueba\main.cpp|26|undefined reference to `_imp___ZNK2sf11SoundBuffer16GetChannelsCountEv'|
C:\Documents and Settings\Administrador\Mis documentos\asd\Prueba\main.cpp|29|undefined reference to `_imp___ZN2sf5SoundC1ERKNS_11SoundBufferEbffRKNS_7Vector3IfEE'|
C:\Documents and Settings\Administrador\Mis documentos\asd\Prueba\main.cpp|30|undefined reference to `_imp___ZN2sf5Sound4PlayEv'|
C:\Documents and Settings\Administrador\Mis documentos\asd\Prueba\main.cpp|39|undefined reference to `_imp___ZNK2sf5Sound16GetPlayingOffsetEv'|
C:\Documents and Settings\Administrador\Mis documentos\asd\Prueba\main.cpp|33|undefined reference to `_imp___ZNK2sf5Sound9GetStatusEv'|
C:\Documents and Settings\Administrador\Mis documentos\asd\Prueba\main.cpp|41|undefined reference to `_imp___ZN2sf5SoundD1Ev'|
C:\Documents and Settings\Administrador\Mis documentos\asd\Prueba\main.cpp|41|undefined reference to `_imp___ZN2sf5SoundD1Ev'|
C:\Documents and Settings\Administrador\Mis documentos\asd\Prueba\main.cpp|41|undefined reference to `_imp___ZN2sf11SoundBufferD1Ev'|
C:\Documents and Settings\Administrador\Mis documentos\asd\Prueba\main.cpp|41|undefined reference to `_imp___ZN2sf11SoundBufferD1Ev'|
obj\Debug\main.o||In function `Z9PlayMusicv':|
C:\Documents and Settings\Administrador\Mis documentos\asd\Prueba\main.cpp|52|undefined reference to `_imp___ZN2sf5MusicC1Ej'|
C:\Documents and Settings\Administrador\Mis documentos\asd\Prueba\main.cpp|53|undefined reference to `_imp___ZN2sf5Music12OpenFromFileERKSs'|
C:\Documents and Settings\Administrador\Mis documentos\asd\Prueba\main.cpp|58|undefined reference to `_imp___ZNK2sf5Music11GetDurationEv'|
C:\Documents and Settings\Administrador\Mis documentos\asd\Prueba\main.cpp|59|undefined reference to `_imp___ZNK2sf11SoundStream13GetSampleRateEv'|
C:\Documents and Settings\Administrador\Mis documentos\asd\Prueba\main.cpp|60|undefined reference to `_imp___ZNK2sf11SoundStream16GetChannelsCountEv'|
C:\Documents and Settings\Administrador\Mis documentos\asd\Prueba\main.cpp|63|undefined reference to `_imp___ZN2sf11SoundStream4PlayEv'|
C:\Documents and Settings\Administrador\Mis documentos\asd\Prueba\main.cpp|72|undefined reference to `_imp___ZNK2sf11SoundStream16GetPlayingOffsetEv'|
C:\Documents and Settings\Administrador\Mis documentos\asd\Prueba\main.cpp|66|undefined reference to `_imp___ZNK2sf11SoundStream9GetStatusEv'|
C:\Documents and Settings\Administrador\Mis documentos\asd\Prueba\main.cpp|74|undefined reference to `_imp___ZN2sf5MusicD1Ev'|
C:\Documents and Settings\Administrador\Mis documentos\asd\Prueba\main.cpp|74|undefined reference to `_imp___ZN2sf5MusicD1Ev'|
||=== Build finished: 23 errors, 0 warnings ===|

the code is these:

Code: [Select]

////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Audio.hpp>
#include <iomanip>
#include <iostream>


////////////////////////////////////////////////////////////
/// Play a sound
///
////////////////////////////////////////////////////////////
void PlaySound()
{
    // Load a sound buffer from a wav file
    sf::SoundBuffer Buffer;
    if (!Buffer.LoadFromFile("datas/sound/footsteps.wav"))
        return;


    // Display sound informations
    std::cout << "footsteps.wav :" << std::endl;
    std::cout << " " << Buffer.GetDuration()      << " sec"           << std::endl;
    std::cout << " " << Buffer.GetSampleRate()    << " samples / sec" << std::endl;
    std::cout << " " << Buffer.GetChannelsCount() << " channels"      << std::endl;

    // Create a sound instance and play it
    sf::Sound Sound(Buffer);
    Sound.Play();

    // Loop while the sound is playing
    while (Sound.GetStatus() == sf::Sound::Playing)
    {
        // Leave some CPU time for other processes
        sf::Sleep(0.1f);

        // Display the playing position
        std::cout << "\rPlaying... " << std::fixed << std::setprecision(2) << Sound.GetPlayingOffset() << " sec   ";
    }
    std::cout << std::endl << std::endl;
}


////////////////////////////////////////////////////////////
/// Play a music
///
////////////////////////////////////////////////////////////
void PlayMusic()
{
    // Load an ogg music file
    sf::Music Music;
    if (!Music.OpenFromFile("datas/sound/lepidoptera.ogg"))
        return;

    // Display music informations
    std::cout << "lepidoptera.ogg :" << std::endl;
    std::cout << " " << Music.GetDuration()      << " sec"           << std::endl;
    std::cout << " " << Music.GetSampleRate()    << " samples / sec" << std::endl;
    std::cout << " " << Music.GetChannelsCount() << " channels"      << std::endl;

    // Play it
    Music.Play();

    // Loop while the music is playing
    while (Music.GetStatus() == sf::Music::Playing)
    {
        // Leave some CPU time for other processes
        sf::Sleep(0.1f);

        // Display the playing position
        std::cout << "\rPlaying... " << std::fixed << std::setprecision(2) << Music.GetPlayingOffset() << " sec   ";
    }
    std::cout << std::endl;
}


////////////////////////////////////////////////////////////
/// Entry point of application
///
/// \return Application exit code
///
////////////////////////////////////////////////////////////
int main()
{
    // Play a sound
    PlaySound();

    // Play a music
    PlayMusic();

    // Wait until the user presses 'enter' key
    std::cout << "Press enter to exit..." << std::endl;
    std::cin.ignore(10000, '\n');

    return EXIT_SUCCESS;
}


it is the audio sample

Wizzard

  • Full Member
  • ***
  • Posts: 213
    • View Profile
undefined reference to `sf::SoundBuffer::SoundBuffer()'
« Reply #5 on: May 05, 2011, 12:53:19 am »
You are not setting up the project correctly in Code::Blocks.