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

Author Topic: SFML Audio keeps giving errors  (Read 5120 times)

0 Members and 1 Guest are viewing this topic.

nicknicknick111

  • Newbie
  • *
  • Posts: 3
    • View Profile
SFML Audio keeps giving errors
« on: July 19, 2015, 08:39:32 pm »
I have sfml installed to my codeblocks, and the graphics part has been working great. I'm following some youtube tutorials that just covered audio, yet when I try running the code that I am taught, I get a ton of errors. I've spent so many hours looking for a solution to this; I REALLY need some help right now and would appreciate anything

Here's my code:

#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include <string>
#include <iostream>

int main(){ //IMPORTANT: use .wav files for sound effects, and use .ogg files for long background songs etc.

    sf::Vector2i screenDimensions(800,600);

    sf::RenderWindow Window;
    Window.create(sf::VideoMode(screenDimensions.x, screenDimensions.y), "A Window");

    sf::Clock clock;

    sf::SoundBuffer soundBuffer;
    sf::Sound sound;

    if(!soundBuffer.loadFromFile("punch.ogg")){
        std::cout << "Can't find audio file" << std::endl;
    }

    sound.setBuffer(soundBuffer);

    float moveSpeed = 10000.0f;

    while(Window.isOpen()){

        clock.restart();
        sf::Event Event;
        while(Window.pollEvent(Event)){

            switch(Event.type){
            case sf::Event::Closed:
                Window.close();
                break;
            case sf::Event::KeyPressed:
                if(Event.key.code == sf::Keyboard::Escape){
                    Window.close();
                }
                if(Event.key.code == sf::Keyboard::P){
                    sound.play(); //there's also sound.pause(), that is resumed with play(), but also sound.stop() that resets the sound when next played
                }
                break;
            }
        }

        Window.display();
        Window.clear();
        }
}

Here's all of the linker settings (I've done the #define's and the other stuff so I don't think the issue could actually be that)

sfml-audio-s-d
sfml-network-s-d
sfml-graphics-s-d
sfml-window-s-d
sfml-system-s-d
flac
ogg
vorbis
vorbisenc
vorbisfile
openal32
jpeg
freetype
ws2_32
gdi32
opengl32
winmm

And lastly, all of the wonderful errors:

E:\CODING STUFF FOR C++\zzz.External Libraries\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_write'|
E:\CODING STUFF FOR C++\zzz.External Libraries\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_write'|
E:\CODING STUFF FOR C++\zzz.External Libraries\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_write'|
E:\CODING STUFF FOR C++\zzz.External Libraries\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_write'|
E:\CODING STUFF FOR C++\zzz.External Libraries\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_write'|
E:\CODING STUFF FOR C++\zzz.External Libraries\SFML-2.3\lib\libvorbis.a(info.o):info.c|| more undefined references to `oggpack_write' follow|
E:\CODING STUFF FOR C++\zzz.External Libraries\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_readinit'|
E:\CODING STUFF FOR C++\zzz.External Libraries\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_read'|
E:\CODING STUFF FOR C++\zzz.External Libraries\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_read'|
E:\CODING STUFF FOR C++\zzz.External Libraries\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_readinit'|
E:\CODING STUFF FOR C++\zzz.External Libraries\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_read'|
E:\CODING STUFF FOR C++\zzz.External Libraries\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_read'|
E:\CODING STUFF FOR C++\zzz.External Libraries\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_read'|
E:\CODING STUFF FOR C++\zzz.External Libraries\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_read'|
E:\CODING STUFF FOR C++\zzz.External Libraries\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_read'|
E:\CODING STUFF FOR C++\zzz.External Libraries\SFML-2.3\lib\libvorbis.a(info.o):info.c|| more undefined references to `oggpack_read' follow|
E:\CODING STUFF FOR C++\zzz.External Libraries\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_bytes'|
E:\CODING STUFF FOR C++\zzz.External Libraries\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_read'|
E:\CODING STUFF FOR C++\zzz.External Libraries\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_bytes'|
E:\CODING STUFF FOR C++\zzz.External Libraries\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_read'|
E:\CODING STUFF FOR C++\zzz.External Libraries\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_read'|
E:\CODING STUFF FOR C++\zzz.External Libraries\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_read'|
E:\CODING STUFF FOR C++\zzz.External Libraries\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_read'|
E:\CODING STUFF FOR C++\zzz.External Libraries\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_read'|
E:\CODING STUFF FOR C++\zzz.External Libraries\SFML-2.3\lib\libvorbis.a(info.o):info.c|| more undefined references to `oggpack_read' follow|
E:\CODING STUFF FOR C++\zzz.External Libraries\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_writeinit'|
E:\CODING STUFF FOR C++\zzz.External Libraries\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_bytes'|
E:\CODING STUFF FOR C++\zzz.External Libraries\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_bytes'|
E:\CODING STUFF FOR C++\zzz.External Libraries\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_bytes'|
E:\CODING STUFF FOR C++\zzz.External Libraries\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_writeclear'|
E:\CODING STUFF FOR C++\zzz.External Libraries\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_writeclear'|
E:\CODING STUFF FOR C++\zzz.External Libraries\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_writeinit'|
E:\CODING STUFF FOR C++\zzz.External Libraries\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_write'|
E:\CODING STUFF FOR C++\zzz.External Libraries\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_write'|
E:\CODING STUFF FOR C++\zzz.External Libraries\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_write'|
E:\CODING STUFF FOR C++\zzz.External Libraries\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_write'|
E:\CODING STUFF FOR C++\zzz.External Libraries\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_write'|
E:\CODING STUFF FOR C++\zzz.External Libraries\SFML-2.3\lib\libvorbis.a(info.o):info.c|| more undefined references to `oggpack_write' follow|
E:\CODING STUFF FOR C++\zzz.External Libraries\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_bytes'|
E:\CODING STUFF FOR C++\zzz.External Libraries\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_bytes'|
E:\CODING STUFF FOR C++\zzz.External Libraries\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_bytes'|
E:\CODING STUFF FOR C++\zzz.External Libraries\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_reset'|
E:\CODING STUFF FOR C++\zzz.External Libraries\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_writeclear'|
E:\CODING STUFF FOR C++\zzz.External Libraries\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_bytes'|
E:\CODING STUFF FOR C++\zzz.External Libraries\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_bytes'|
E:\CODING STUFF FOR C++\zzz.External Libraries\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_bytes'|
E:\CODING STUFF FOR C++\zzz.External Libraries\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_reset'|
E:\CODING STUFF FOR C++\zzz.External Libraries\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_write'|
E:\CODING STUFF FOR C++\zzz.External Libraries\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_write'|
E:\CODING STUFF FOR C++\zzz.External Libraries\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_write'|
||More errors follow but not being shown.|
||Edit the max errors limit in compiler options...|
||=== Build finished: 50 errors, 0 warnings (0 minutes, 2 seconds) ===|

G.

  • Hero Member
  • *****
  • Posts: 1593
    • View Profile
Re: SFML Audio keeps giving errors
« Reply #1 on: July 19, 2015, 10:43:22 pm »
Try the same order as in the tutorial:
openal32
flac
vorbisenc
vorbisfile
vorbis
ogg
instead of your
flac
ogg
vorbis
vorbisenc
vorbisfile
openal32

And when you post the same question on several websites you could warn people about it, so that they won't waste their time answering whereas it has already been answered somewhere else.

nicknicknick111

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: SFML Audio keeps giving errors
« Reply #2 on: July 21, 2015, 03:54:05 am »
sorry about the other website issue, I had not been, and still have not, been given an adequate answer on that site and figured that the best place to get an answer for a SFML question would be on its own site. Anyways, I reordered it as you said and nothing changed, same errors, same sad me

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: SFML Audio keeps giving errors
« Reply #3 on: July 21, 2015, 07:37:17 am »
Quote
I reordered it as you said
Are you sure? It really looks like an order issue between vorbis and ogg, so this should fix it.
Laurent Gomila - SFML developer

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: SFML Audio keeps giving errors
« Reply #4 on: July 21, 2015, 03:05:28 pm »
On a completely unrelated note, I just wanted to point out that you're not even following your own "important" advice  ;D
//IMPORTANT: use .wav files for sound effects, and use .ogg files for long background songs etc.
...
soundBuffer.loadFromFile("punch.ogg")

(although ogg for sound effects is perfectly fine)
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11033
    • View Profile
    • development blog
    • Email
AW: Re: SFML Audio keeps giving errors
« Reply #5 on: July 22, 2015, 02:09:14 pm »
Anyways, I reordered it as you said and nothing changed, same errors, same sad me
You need to make full clean rebuild once you changes the order for all targets.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

nicknicknick111

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: SFML Audio keeps giving errors
« Reply #6 on: July 28, 2015, 04:16:10 am »
idk what I did wrong but I guess I mistyped what you told me to change in the linker settings. I LOVE YOU SO MUCH FOR HELPING ME. and the reason I used the wrong file format was just to test if that was the issue lol ;D ;D ;D