libsdl-org / SDL_mixer

An audio mixer that supports various file formats for Simple Directmedia Layer.
zlib License
433 stars 146 forks source link

Latest Source: Failed loading ModPlug_Tell: [not found] #407

Closed AntTheAlchemist closed 2 years ago

AntTheAlchemist commented 2 years ago

When using libmodplug-1.dll, I get the above run time error from the latest source build.

sezero commented 2 years ago

It is correct that libmodplug-1.dll files under VisualC/external/lib/x86 and VisualC/external/lib/x64 don't have that symbol, however the source is supposed to be attempting to load it at runtime and not fail if it is not found: https://github.com/libsdl-org/SDL_mixer/blob/main/src/codecs/music_modplug.c#L84

Such an error could have only happened if MODPLUG_DYNAMIC is not defined and MODPLUG_HAS_TELL is defined during SDL2_mixer build, and we do not define MODPLUG_HAS_TELL anywhere.

How are you compiling SDL2_mixer?

sezero commented 2 years ago

I am curious though: How do you actually see the error you reported? Does the library actually work fine, but you just call SDL_GetError and see the error that way? If it really happens that way, do you actually receive any failures and is that the reason you are calling SDL_GetError, or do you intend to check presence of any errors by calling SDL_GetError (which would be a wrong thing to do)?

AntTheAlchemist commented 2 years ago

I'm using the VisualC project and VS2022. I did dig around in the code and played with MODPLUG_DYNAMIC, which didn't seem to make a difference.

I've been playing with other compiler options and it no longer does it. It was only happening on the debug version at one point.

Everything still works fine, yes. The error is set by Mix_Init(). I've relied on SDL_GetError() reporting no problem up to now.

sezero commented 2 years ago

Everything still works fine, yes. The error is set by Mix_Init(). I've relied on SDL_GetError() reporting no problem up to now.

Mix_Init should return 0 on failure: If you don't hit that but still call SDL_GetError, you can get error even though it is irrelevant to you. I.e.: Only check Mix_Init return value for error. This is not a bug, closing.

madebr commented 2 years ago

While triaging https://github.com/libsdl-org/SDL_mixer/issues/435#issuecomment-1214063419, I saw this message when building SDL_mixer using CMake, and setting the log priority to SDL_LOG_PRIORITY_VERBOSE:

cmake_minimum_required(VERSION 3.20)
project(myproject C)

include(FetchContent)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")

FetchContent_Declare(
    SDL2
    GIT_REPOSITORY https://github.com/libsdl-org/SDL.git
    GIT_TAG release-2.0.22
    GIT_PROGRESS TRUE
)
FetchContent_Declare(
        SDL2_mixer
        GIT_REPOSITORY https://github.com/libsdl-org/SDL_mixer.git
        GIT_TAG release-2.6.1
        GIT_PROGRESS TRUE
)
FetchContent_MakeAvailable(SDL2 SDL2_mixer)

file(WRITE main.c [[
#define SDL_MAIN_HANDLED
#include "SDL.h"
#include "SDL_mixer.h"
#include <stdio.h>
#include <stdlib.h>

#define MIX_INIT_FLAGS (MIX_INIT_FLAC | MIX_INIT_MOD | MIX_INIT_MP3| MIX_INIT_OGG | MIX_INIT_MID | MIX_INIT_OPUS)

int main(int argc, char *argv[]) {
    int ret;
    SDL_SetMainReady();
    SDL_Init(SDL_INIT_AUDIO);
    SDL_LogSetAllPriority(SDL_LOG_PRIORITY_VERBOSE);
    ret = Mix_Init(MIX_INIT_FLAGS);
    printf("Expected 0x%x, got 0x%x\n", MIX_INIT_FLAGS, ret);
    if (ret != MIX_INIT_FLAGS) {
        printf("WRONG!\n");
        abort();
    }
    Mix_Quit();
    SDL_Quit();
    return 0;
}
]])
add_executable(main main.c)
target_link_libraries(main PRIVATE SDL2::SDL2 SDL2_mixer::SDL2_mixer)
sezero commented 2 years ago

While triaging #435 (comment),

Can someone change the title of that ticket? I still don't know whact exactly it is about.

I saw this message when building SDL_mixer using CMake, and setting the log priority to SDL_LOG_PRIORITY_VERBOSE:

If you are seeing that Failed loading ModPlug_Tell: [not found] message, it doesn't mean anything, really. If it's another error message, please post.

sezero commented 2 years ago

I went ahead and pushed https://github.com/libsdl-org/SDL_mixer/commit/de25435d2d8e7c2f3e5db15b161e313a868af149 to avoid confusions like this.