emscripten-core / emscripten

Emscripten: An LLVM-to-WebAssembly Compiler
Other
25.62k stars 3.28k forks source link

SDL2 mixer compilation problem #7879

Closed paulocoutinhox closed 4 years ago

paulocoutinhox commented 5 years ago

Hi,

When i use "-s USE_SDL_MIXER=2", i got compilation errors using emscripten version 1.38.24:

emscripten:INFO: generating port: sdl2-mixer.bc... (this will be cached in "/Users/paulo/.emscripten_cache/asmjs/sdl2-mixer.bc" for subsequent builds)
shared:ERROR: no input files
note that input files without a known suffix are ignored, make sure your input files end with one of: ('.c', '.C', '.i', '.cpp', '.cxx', '.cc', '.c++', '.CPP', '.CXX', '.CC', '.C++', '.ii', '.m', '.mi', '.mm', '.mii', '/dev/null', '.bc', '.o', '.obj', '.lo', '.dylib', '.so', '.a', '.ll', '.h', '.hxx', '.hpp', '.hh', '.H', '.HXX', '.HPP', '.HH')
emscripten sdl2-config called with /Users/paulo/Developer/emsdk/emscripten/1.38.24/system/bin/sdl2-config --cflags
emscripten sdl2-config called with /Users/paulo/Developer/emsdk/emscripten/1.38.24/system/bin/sdl2-config --libs
emscripten sdl2-config called with /Users/paulo/Developer/emsdk/emscripten/1.38.24/system/bin/sdl2-config --version
emscripten sdl2-config called with /Users/paulo/Developer/emsdk/emscripten/1.38.24/system/bin/sdl2-config --version
emscripten sdl2-config called with /Users/paulo/Developer/emsdk/emscripten/1.38.24/system/bin/sdl2-config --version
configure: WARNING: MOD support disabled
configure: WARNING: MIDI support disabled
configure: WARNING: vorbis/vorbisfile.h: accepted by the compiler, rejected by the preprocessor!
configure: WARNING: vorbis/vorbisfile.h: proceeding with the compiler's result
configure: WARNING: MP3 support disabled
shared:WARNING: emcc: cannot find library "vorbisfile"
shared:WARNING: emcc: cannot find library "vorbis"
shared:WARNING: emcc: cannot find library "vorbisfile"
shared:WARNING: emcc: cannot find library "vorbis"

Can anyone help me?

kripken commented 5 years ago

Using SDL_MIXER=2 should automatically get vorbis, https://github.com/emscripten-core/emscripten/blob/incoming/tools/ports/sdl_mixer.py#L38 - so I think those warnings about vorbis are mistaken. Might be true about mp3 though.

We should probably have a mechanism that makes -lvorbis work if USE_VORBIS was set. Or vice versa.

indianakernick commented 5 years ago

I'm having the same problem with 1.38.31. I'm compiling with -s USE_SDL_MIXER=2 -s USE_OGG=1 -s USE_VORBIS=1. Mix_Init(MIX_INIT_OGG) returns 0 and Mix_GetError() returns "Mixer not built with Ogg Vorbis support". I tried emcc --clear-cache with no luck.

What do I do?

indianakernick commented 5 years ago

@kripken BTW, I was previously using the SDL2 audio callback in combination with stb_vorbis to play music. It can be a little stuttery and SDL_PauseAudioDevice doesn't actually pause (it just loops the previous chunk).

Is Mix_PlayMusic better?

If I can't get this to work then perhaps I'd have better luck with inline JavaScript?

divVerent commented 5 years ago

I can confirm the issue - it seems like the issue is that libvorbisfile is not installed as part of the vorbis port.

Any fix idea for that?

divVerent commented 5 years ago

Looks like as a temporary workaround, I can cancel the build of SDL2_mixer when it detects that vorbis is missing, then edit ~/.emscripten_ports/sdl2_mixer/SDL2_mixer-release-2.0.1/configure and remove all references to -logg, -lvorbis and -lvorbisfile. After that it'll build a working version of SDL2_mixer.

As the configure script hardcodes these flags, I see only two real solutions:

makryl commented 4 years ago

Same here. Before issue i worked with version 1.38.29, updated to latest 1.39.0 and got no ogg support in SDL_mixer. Tried next sdk versions: sdk-1.38.31-64bit, 1.38.33, 1.38.40, 1.39.0 - same issue with log:

checking vorbis/vorbisfile.h usability... yes
checking vorbis/vorbisfile.h presence... no
configure: WARNING: vorbis/vorbisfile.h: accepted by the compiler, rejected by the preprocessor!
configure: WARNING: vorbis/vorbisfile.h: proceeding with the compiler's result
checking for vorbis/vorbisfile.h... yes
checking for ov_open_callbacks in -lvorbisfile -lvorbis -logg -lm... no
configure: WARNING: *** Unable to find Ogg Vorbis library (http://www.xiph.org/)
configure: WARNING: Ogg Vorbis support disabled

Found only one of available at the moment version sdk-1.38.30-64bit compiles SDL_mixer with ogg support:

checking vorbis/vorbisfile.h usability... yes
checking vorbis/vorbisfile.h presence... no
configure: WARNING: vorbis/vorbisfile.h: accepted by the compiler, rejected by the preprocessor!
configure: WARNING: vorbis/vorbisfile.h: proceeding with the compiler's result
checking for vorbis/vorbisfile.h... yes
checking for ov_open_callbacks in -lvorbisfile -lvorbis -logg -lm... yes
sbc100 commented 4 years ago

So if I understand correctly was broken in 1.38.33 and 1.38.40? And I assume you were using fastcomp in those versions? So it seems this is not related to the upstream switch but happened some time before?

makryl commented 4 years ago

broken in latest 1.39.0 upstream too

makryl commented 4 years ago

i did not test all available versions, but looks like it was broken since 1.38.31 till latest 1.39.0. Also i tested latest 1.39.0 upstream and fastcomp - both broken

makryl commented 4 years ago

So it seems this is not related to the upstream switch but happened some time before?

I think yes. Looks like it was near 1.38.30 -> 1.38.31, and there was no upstream yet.

kripken commented 4 years ago

I think the key issue here is in https://github.com/emscripten-core/emscripten/issues/7879#issuecomment-455395415 - if USE_VORBIS is set, we need to make that work with SDL2_mixer, which for some reason doesn't currently. This is not a new issue, but it would definitely be good to fix if someone has time to look into it.

Oipo commented 4 years ago

I've taken a look at it and it seems that ports/vorbis.py only copies libvorbis.la, missing libvorbisfile.la and libvorbisenc.la. However, I am not familiar enough with the scripts to fix the file. Is there documentation on those somewhere?

kripken commented 4 years ago

@Oipo Each port has a python file that manages it, for SDL2_mixer that is tools/ports/sdl2_mixer.py, for vorbis it's tools/ports/vorbis.py. Not much docs on those files, but they are pretty short. Let me know if you have any questions about the APIs used there!

Oipo commented 4 years ago

@kripken Ah yes, I managed to find those. However, looking at vorbis.py, do I edit https://github.com/emscripten-core/emscripten/blob/incoming/tools/ports/vorbis.py#L35 to return more than one library name? Or do I edit line 28 to copy more?

kripken commented 4 years ago

In general a port should return one output in the current model. Perhaps before line 33 we could link all the necessary libraries files, if there is more than one?

sbc100 commented 4 years ago

I think we should move away from using configure here and switch to using build_port like the other ports. SDL2_mixer and harfbuzz look like the only two ports that rely on using configure to build the port. This makes them not portable since configure can't run on windows.