SDL2 Mixer issue: Couldn't launch process

587 views Asked by At

I'm running into a problem when using the SDL2 Mixer library in my C++ project. As soon as I'm calling a function on a class that #includes SDL_mixer.h, the project will not run. When trying to Run it, I get the following message:

enter image description here

When debugging the project, the process finishes with exit code 0, but with an additional message:

enter image description here

and

enter image description here

As you might be able to deduce, adding breakpoints to the code does not provide any additional information as the project doesn't start at all.

Commenting out the lines that use the class that include mixer makes the project runnable again seemingly without issues. I've tried to google the error code, but I can't find any documentation on what it means.

Other, possibly relevant information: I'm using conan to install my libraries and have it set to auto-install any dependencies.

I'll post the header code of the class in question here, though I don't believe the problem lies here as the project won't run to even reach the code anyway.

#include <SDL.h>
#include <SDL_mixer.h>
#include <memory>
#include <string>
#include <map>

class SoundService {
public:

    /*******************************************************************************
        * @brief Gets the singleton instance of the SoundService class.
         *
         * @return A reference to the instance of the SoundService.
         ******************************************************************************/
    static std::unique_ptr<SoundService> &getInstance() {
        if (instance == nullptr) {
            if(Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 4096) < 0){
                SDL_Log("Mixer Initialization Error: %s", Mix_GetError());
            }
            instance = std::unique_ptr<SoundService>(new SoundService());
        }

        return instance;
    }

    /**
     * @brief Loads a music file and stores it with a given id string.
     * @param id
     * @param filePath
     * @return True if the asset has been loaded successfully, otherwise false.
     */
    bool loadMusic(const std::string &id, const std::string &filePath);

    void playMusic(const std::string &id, int loops = -1);

    void pauseMusic();

    void resumeMusic();

    /**
     * @brief Removes a music file by id.
     * @param id
     * @return True if the asset has been removed successfully, otherwise false.
     */
    bool removeMusic(std::string &id);

    /**
     * @brief Loads an sfx file and stores it with a given id string.
     * @param id
     * @param filePath
     * @return True if the asset has been loaded successfully, otherwise false.
     */
    bool loadSFX(const std::string &id, const std::string &filePath);

    void playSFX(const std::string &id, int loops = 0, int channel = 0);

    /**
     * @brief Removes an sfx file by id.
     * @param id
     * @return True if the asset has been removed successfully, otherwise false.
     */
    bool removeSFX(std::string &id);

    /**
     * @brief Removes all the music files and sfx files from the sound service
     */
    void clear();

private:
    SoundService() = default;

    static std::unique_ptr<SoundService> instance;

    std::map<std::string, Mix_Music *> musicMap;
    std::map<std::string, Mix_Chunk *> sfxMap;
};

The function that I'm calling that breaks the project is just a simple line of testcode:

auto& soundService = SoundService::getInstance();

Here is the conanfile used to declare the required libraries:

from conans import ConanFile, CMake
from conans.tools import os_info

class ModularMagicConan(ConanFile):
    name = "ModularMagic"
    version = "0.1"
    url = "edited out"
    description = "A 2D game"
    settings = "os", "compiler", "build_type", "arch"
    generators = "cmake"

    def requirements(self):
        self.requires("sdl2/2.0.12@bincrafters/stable")         # SDL2, rendering and window creation library
        self.requires("sdl2_image/2.0.5@bincrafters/stable")    # SDL2 image, texture library
        self.requires("sdl2_mixer/2.0.4@bincrafters/stable")    # SDL2 mixer, sound library
        self.requires("gtest/1.10.0")                           # Used for unit testing
        self.requires("box2d/2.4.0")                            # Box2D, physics library


    def build(self):
        cmake = CMake(self)
        cmake.configure()
        cmake.build()

    def test(self):
        cmake.test()

Anyone familiar with this issue or has any idea what's causing it and how to resolve it?

3

There are 3 answers

0
Bart K On

Well, I don't know if it really counts as an answer, but perhaps it will help others with the same problem. Me and a colleague found this sketchy suggestion somewhere to throw a copy of glib-2.0-0.dll (which you should be able to find in a .conan folder in your :C drive) in System32. This somehow works, I can run my project now. I don't know if this is something that's wrong with SDL_mixer, as it certainly doesn't seem like the right way to solve it, but at least I can work on my project again.

8
xryl669 On

Error 0xC0000135 is usually related to .NET framework issues. It also appears when some windows service can not start.

If I were you, I'd check the system's Event Viewer (I assume you are using Windows OS) to get more details about these. You'll find such application by following this tutorial

0
Jacckx On

got the same problem in CLion. fixed it by copying all the .dll in SDL2_mixer and put them in the same directory as your .exe file.see picture here