SDL_mixer: Android build with SDL2MIXER_FLAC=ON can't find libFLAC.so
The build can’t find libFLAC.so with SDL2MIXER_FLAC=ON on an Android build, causing the build to fail:
$ ./gradlew build
...
> Task :buildCMakeDebug FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':buildCMakeDebug'.
> Expected output file at /project-name/android/build/intermediates/cxx/Debug/6w2m3w14/obj/arm64-v8a/libFLAC.so for target FLAC but there was none
...
CMakeLists.txt:
cmake_minimum_required( VERSION 3.18.0 )
cmake_policy( SET CMP0091 NEW )
project( appname )
set( SDL_LIBC ON CACHE BOOL "" FORCE )
set( SDL_TEST OFF CACHE BOOL "" FORCE )
# https://github.com/libsdl-org/SDL.git
# release-2.24.1
add_subdirectory( external/sdl )
set( BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE )
set( SDL2MIXER_FLAC ON CACHE BOOL "" FORCE )
set( SDL2MIXER_OPUS OFF CACHE BOOL "" FORCE )
set( SDL2MIXER_SAMPLES OFF CACHE BOOL "" FORCE )
set( SDL2MIXER_VENDORED ON CACHE BOOL "" FORCE )
# https://github.com/libsdl-org/SDL_mixer.git
# HEAD of 'main' branch as of today: db9da3d416077195a2f84403b2fb40955518b4ab
add_subdirectory( external/sdl-mixer )
set( SRCS "src/main.cpp" )
set( LIBS
SDL2::SDL2main
SDL2::SDL2-static
SDL2_mixer::SDL2_mixer-static
)
if( ${CMAKE_SYSTEM_NAME} MATCHES "Android")
add_library( main SHARED ${SRCS} )
target_link_libraries( main ${LIBS} )
else()
add_executable( ${CMAKE_PROJECT_NAME} ${SRCS} )
target_link_libraries( ${CMAKE_PROJECT_NAME} ${LIBS} )
endif()
src/main.cpp:
#include <SDL.h>
#include <SDL_mixer.h>
int main( int argc, char** argv )
{
SDL_Init( SDL_INIT_EVERYTHING );
SDL_Quit();
return 0;
}
The same CMakeLists.txt builds successfully with SDL2MIXER_FLAC=OFF, as well as on the host Debian 11 system with:
cmake -B build -G "Ninja Multi-Config" .
cmake --build build --config Release --parallel $(nproc)
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 22 (14 by maintainers)
Thanks. I can reproduce in a docker container. It’s really weird. Running
gradle build --infoshows the build command that is used.Let’s try running the build command manually:
Now
libFLAC.sois there. But running./gradlew buildwill remove it again.So it looks like something is removing
libFLAC.so, and I have no idea who/why. The logs don’t show this.I’ve created these build logs, but they don’t contain anything useful (or so I think): https://scans.gradle.com/s/wtlvlp6fu2wjy https://scans.gradle.com/s/ttmmdd5waiiwy
Then let’s upgrade officially in SDL_mixer main branch if there are no complications.
Reported asm build issue to mainstream at https://github.com/xiph/flac/issues/475