Add sdl mixer
You can now play audio and sound effects! I can guarantee that this doesn't work on Windows or Mac, but this is a start. I only got it working on my Linux.
Need to get the lib-files (.dll and .a) for Windows and do some more testing so this actually works on all platforms.
Merge request reports
Activity
assigned to @joakibhu
- Resolved by Joakim Borge Hunskår
- Resolved by Joakim Borge Hunskår
after fixing typo lib files still seem to be missing: subprojects\sdl2_mixer_windows\meson.build:12:22: ERROR: C++ shared or static library 'SDL2_mixer' not found.
Tried adding sdl2_mixer.dll from https://github.com/libsdl-org/SDL_mixer/releases This fixes library error however compiling fails: ..\subprojects\animationwindow\include/Audio.h:5:10: fatal error: 'SDL_mixer.h' file not found 5 | #include <SDL2/SDL_mixer.h>
This should only be <SDL_mixer.h> i think since the whole SDL2 dir is included: include_directories : include_directories(join_paths('include', 'SDL2'))) and but this also fails with the same error.
In image.cpp it is included without SDL2: "#include <SDL_image.h>"
Attempted various different things now, but i am unable to fix the last error
added 2 commits
added 1 commit
- d6adb5ab - Change dependency_libs path in libSDL2_mixer.la
32 32 install_subdir('include', install_dir: '.') 33 33 install_subdir('src', install_dir: '.') 34 34 35 animationwindow_dep = declare_dependency(link_with: animationwindow, include_directories: incdir) according to chat: "Just because a static_library() uses dependencies, doesn't mean those dependencies are automatically exported or visible to other targets that depend on the declare_dependency() wrapping it."
Animation window was still failing to build with: ..\subprojects\animationwindow\include/Audio.h:5:10: fatal error: 'SDL_mixer.h' file not found 5 | #include <SDL2/SDL_mixer.h
another solution is to add the dependency in the root meson.build: `project('testproject', 'cpp', version : '0.1', default_options : ['warning_level=0', 'cpp_std=c++20', 'c_std=c17', 'default_library=static'])
Windows compilation has no pre-packaged SDL2 available, and compilation takes a while.
If you want to compile from source, remove everything but the contents of the else clause.
if host_machine.system() == 'windows' sdl2_dep = subproject('sdl2_windows').get_variable('sdl2_windows_dep') ** sdl2mixer_dep = subproject('sdl2_mixer_windows').get_variable('sdl2_mixer_windows_dep')** else sdl2_dep = dependency('sdl2') endif
animationwindow_dep = dependency('animationwindow', fallback: ['animationwindow', 'animationwindow_dep'])
src = []
exe = executable( 'program', src, 'nuklear_sample.cpp', 'testproject_featuredemo.cpp', ** dependencies : [animationwindow_dep, sdl2_dep,sdl2mixer_dep]** )`