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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - ArchBTW

Pages: [1]
1
Just started playing around with SFML today. When I downloaded it and used the code from the SFML and Linux tutorial everything worked fine, but when I tried to use the Audio headers it caused the linker to crash with errors about undefined references to everything from the Audio header files like sf::Music and such.
I have the header & lib files in the right place and the right compile commands. I am not sure whats wrong.

I use arch linux, g++ and vs code(I compile in the terminal not in vs code)

the code that causes ld to crash
// Load a music to play
sf::Music music;
if (!music.openFromFile("music.ogg"))
        return EXIT_FAILURE;
// Play the music
music.play();

the errors
/usr/bin/ld: main.o: in function `main':
main.cpp:(.text+0x1f3): undefined reference to `sf::Music::Music()'
/usr/bin/ld: main.cpp:(.text+0x23b): undefined reference to `sf::Music::openFromFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/bin/ld: main.cpp:(.text+0x278): undefined reference to `sf::SoundStream::play()'
/usr/bin/ld: main.cpp:(.text+0x28c): undefined reference to `sf::Music::~Music()'
/usr/bin/ld: main.cpp:(.text+0x32f): undefined reference to `sf::Music::~Music()'
collect2: error: ld returned 1 exit status

compilation commands
g++ -c main.cpp -I /usr/include
g++ main.o -o sfml-app -L /usr/lib -lsfml-graphics -lsfml-window -lsfml-system


Pages: [1]
anything