miniaudio icon indicating copy to clipboard operation
miniaudio copied to clipboard

wasm/emscripten compilation error

Open gdevillele opened this issue 3 years ago • 4 comments

When trying to compile miniaudio with emscripten, I get the following error

miniaudio/miniaudio.h:61864:12: error: use of undeclared identifier 'strcasecmp'

does this ring a bell to anyone by any chance ? I don't understand why it's not working. I see <strings.h> is included alright 🤔

Thank you.

gdevillele avatar Jul 18 '22 07:07 gdevillele

This is strange. I just tried the dev branch just now and it's compiling just fine for me. I don't have an explanation for this one. Have you tried compiling the simple_playback_sine example?

mackron avatar Jul 21 '22 00:07 mackron

Thank you for confirming it works for you. Let me check this example. ☝️

I might have to tweak by compilation settings...

gdevillele avatar Jul 22 '22 21:07 gdevillele

Did you ever figure this one out? Just checking if I can close this ticket.

mackron avatar Aug 03 '22 21:08 mackron

not yet, sorry, but I will figure it out this week and post an update here.

gdevillele avatar Aug 08 '22 06:08 gdevillele

I don't have time to work on wasm right now, I'm closing this and will reopen if needed when I'm back on wasm stuff. Thanks.

gdevillele avatar Aug 29 '22 07:08 gdevillele

Update :

I tried compiling simple_playback_sine example like you suggested and I had no issue. But I still cannot compile my own code due to the use of strcasecmp.

I am wondering if it's because the example doesn't use the miniaudio functions that are using strcasecmp and they are stripped somehow 🤔

If that's fine with you, I'll open a PR in with I replace strcasecmp by a to_lower + strcmp combination. :)

gdevillele avatar Dec 10 '22 08:12 gdevillele

Oh, I know how those functions are "stripped".

It the use of

#define MA_NO_DECODING
#define MA_NO_ENCODING

in the simple_playback_sine example.

gdevillele avatar Dec 10 '22 08:12 gdevillele

This is a problem with your build environment. I'm not replicating this, even when commenting out those two lines, and you're the only one whose reporting this problem. I don't have an explanation on what specifically is causing it.

What version of emcc are you using, and what flags are you using with emcc? This is mine:

emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.24 (68a9f990429e0bcfb63b1cde68bad792554350a5)
clang version 16.0.0 (https://github.com/llvm/llvm-project 277c382760bf9575cfa2eac73d5ad1db91466d3f)
Target: wasm32-unknown-emscripten
Thread model: posix

And I just compile like this:

emcc ../simple_playback_sine.c -o bin/simple_playback_sine.html

mackron avatar Dec 10 '22 10:12 mackron

Oh, you are right! I can compile miniaudio alright in other contexts than my project. 😐 Sorry for wasting your time... and thanks a lot for your help.

I am using cmake (and emcmake), with an included CMakeList file compiling the Miniaudio implementation... I am still debugging this issue as I don't know the reason for it yet.

gdevillele avatar Dec 13 '22 08:12 gdevillele

I'll keep debugging this on my end. Thanks again!

gdevillele avatar Dec 19 '22 10:12 gdevillele