Skip to content
Snippets Groups Projects

Add sdl mixer

Open Joakim Borge Hunskår requested to merge add-sdl_mixer into main
2 unresolved threads

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

Approval is optional
Ready to merge by members who can write to the target branch.
  • 17 commits and 1 merge commit will be added to main.
  • Source branch will not be deleted.

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
    • 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 :disappointed:

  • Rory Fitzgerald requested changes

    requested changes

  • added 1 commit

    Compare with previous version

  • added 1 commit

    Compare with previous version

  • added 1 commit

    Compare with previous version

  • added 2 commits

    Compare with previous version

  • added 1 commit

    Compare with previous version

  • added 1 commit

    Compare with previous version

  • added 1 commit

    Compare with previous version

  • added 1 commit

    • d6adb5ab - Change dependency_libs path in libSDL2_mixer.la

    Compare with previous version

  • added 3 commits

    Compare with previous version

  • added 1 commit

    Compare with previous version

  • 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)
    • Why? All of them are dependencies when the static_library is created.

    • 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]** )`

    • this was horribly formatted ups

    • Yeah, SDL2 are already there

    • adding sdl2mixer_dep there works aswell if one doesnt like my previous commit

    • A Windows problem, would it still work if we only added animationwindow as dependency? The build files will become cleaner, but its really no issue

    • yes with my recent commit it works with only animation window as dependency: dependencies : [animationwindow_dep]

    • It should be its own merge request, I can make the change and when this branch is merged we can merge the build file changes.

    • Please register or sign in to reply
    • It works playing sound on my windows now. However i had to manually move the dll files into builddir and the song.mp3 into builddir. But i think this is just since i am compiling manually and running the exe instead of using the extension "run"

    • The filepaths for TDT4102::Image and TDT4102::Audio are relative so if you run the program from the builddir it expects the file to be in the same folder.

      What .dll(s) did you move? We can probably copy it over to builddir as we do with SDL2.dll and SDL2_image.dll

    • i had to copy all the .dll files. SDL2.dll, SDL2_image.dll, and mixerdll. Otherwise i had the classic problem that they could not be found upon running.

    • Just Windows things... Better copy it over to builddir

    • Made a merge request for copying it to builddir

    • Please register or sign in to reply
  • Only missing Mac now

  • added 1 commit

    Compare with previous version

  • Please register or sign in to reply
    Loading