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

Author Topic: compiler errors with audio librarys  (Read 2429 times)

0 Members and 1 Guest are viewing this topic.

jeremiawuzza

  • Newbie
  • *
  • Posts: 9
    • View Profile
    • Email
compiler errors with audio librarys
« on: March 21, 2015, 02:18:39 am »
I am using codeblocks 13.12. I have included the sfml-audio-s-d and  sfml-audio-s libraries in the linker settings (at the bottom of the list). My sample program compiles ok until I uncomment
sf::SoundBuffer sonic ;
then I get this output (I have removed the middle section as it is very similar to the rest).
My cpp file is attached

I am a bit new to C++ & SFML and I have been having great success so far. Now I want to include audio and I have hit a brick wall. No doubt it is something (not very) obvious! any help would be appreciated.

-------------- Build: Debug in SFML_Clock (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe -LD:\SFML-2.2\lib -o bin\Debug\alarm_clock.exe obj\Debug\alarm_clock.o obj\Debug\alarm_clock_library.o obj\Debug\get_time.o obj\Debug\main.o obj\Debug\test_shapes.o   -lsfml-graphics-s-d -lsfml-window-s-d -lsfml-system-s-d -lglew -lopengl32 -lfreetype -ljpeg -lgdi32 -lwinmm -lsfml-audio-s-d
D:\SFML-2.2\lib/libsfml-audio-s-d.a(SoundBuffer.cpp.obj): In function `ZN2sf11SoundBufferC2Ev':
D:/sfml-release/_Sources/SFML/src/SFML/Audio/SoundBuffer.cpp:47: undefined reference to `_imp__alGenBuffers'
D:\SFML-2.2\lib/libsfml-audio-s-d.a(SoundBuffer.cpp.obj): In function `ZN2sf11SoundBufferC2ERKS0_':
D:/sfml-release/_Sources/SFML/src/SFML/Audio/SoundBuffer.cpp:59: undefined reference to `_imp__alGenBuffers'
.........
D:\SFML-2.2\lib/libsfml-audio-s-d.a(SoundSource.cpp.obj): In function `ZN2sf11SoundSourceD2Ev':
D:/sfml-release/_Sources/SFML/src/SFML/Audio/SoundSource.cpp:64: undefined reference to `_imp__alSourcei'
D:/sfml-release/_Sources/SFML/src/SFML/Audio/SoundSource.cpp:65: undefined reference to `_imp__alDeleteSources'
Process terminated with status 1 (0 minute(s), 0 second(s))
50 error(s), 0 warning(s) (0 minute(s), 0 second(s))

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10825
    • View Profile
    • development blog
    • Email
Re: compiler errors with audio librarys
« Reply #1 on: March 21, 2015, 02:44:33 am »
Quote from: SFML Tutorial
Starting from SFML 2.2, when static linking, you will have to link all of SFML's dependencies to your project as well. This means that if you are linking sfml-window-s or sfml-window-s-d for example, you will also have to link opengl32, winmm and gdi32. Some of these dependency libraries might already be listed under "Inherited values", but adding them again yourself shouldn't cause any problems.

The audio module depends on OpenAL, libsndfile, sfml-system and winmm, thus your linking command should be:

-lsfml-graphics-s-d -lsfml-window-s-d -lsfml-audio-s-d -lsfml-system-s-d -lglew -lopengl32 -lfreetype -ljpeg -lgdi32 -lopenal32 -lsndfile -lwinmm
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

G.

  • Hero Member
  • *****
  • Posts: 1592
    • View Profile
Re: compiler errors with audio librarys
« Reply #2 on: March 21, 2015, 02:49:14 am »
Don't forget SFML_STATIC too.

jeremiawuzza

  • Newbie
  • *
  • Posts: 9
    • View Profile
    • Email
Re: compiler errors with audio librarys
« Reply #3 on: March 21, 2015, 07:28:45 am »
Thanks that fixed it - there didn't seem to be anything in the documentation about those other libs, but now I know.
I already had SFML_STATIC in my compiler defines.

jeremiawuzza

  • Newbie
  • *
  • Posts: 9
    • View Profile
    • Email
Re: compiler errors with audio librarys
« Reply #4 on: March 21, 2015, 07:51:38 am »
Or did it fix it? - it only works if I put openal32.dll and libsndfile-1.dll in the project directory. That's despite having SFML_STATIC in my #defines page of compiler settings. None of the other SFML classes I'm using need dll's, though.

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: compiler errors with audio librarys
« Reply #5 on: March 21, 2015, 09:31:24 am »
You can't link the dependencies static due to  their licenses.
Are a few dll's really a big deal anyway?

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: compiler errors with audio librarys
« Reply #6 on: March 21, 2015, 10:49:47 am »
For what it's worth, SFML 2.3 will get rid of libsndfile as a dependency, so from that point on the only DLL you will have to ship would be OpenAL32.dll. There have been investigations into replacing the OpenAL dependency in the past, and is still something up for consideration, but until now we haven't found any suitable candidates yet.
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).