I trying to use emscripten compile ffmpeg through the following script, but I got errors while compiling: (Using Mac pro - Docker ubuntu FFmpeg:4.3.1 and emcc:2.0.1)
make: make
CC libavdevice/alldevices.o
In file included from ./libavutil/internal.h:176:
./libavutil/libm.h:54:32: error: static declaration of 'cbrt' follows non-static declaration
static av_always_inline double cbrt(double x)
^
/home/winixt/emsdk/upstream/emscripten/system/include/libc/math.h:151:13: note: previous declaration is here
double cbrt(double);
^
In file included from ./libavutil/internal.h:176:
./libavutil/libm.h:61:31: error: static declaration of 'cbrtf' follows non-static declaration
static av_always_inline float cbrtf(float x)
^
/home/winixt/emsdk/upstream/emscripten/system/include/libc/math.h:152:13: note: previous declaration is here
float cbrtf(float);
^
In file included from ./libavutil/internal.h:176:
./libavutil/libm.h:68:32: error: static declaration of 'copysign' follows non-static declaration
static av_always_inline double copysign(double x, double y)
^
/home/winixt/emsdk/upstream/emscripten/system/include/libc/math.h:159:13: note: previous declaration is here
double copysign(double, double);
In file included from ./libavutil/internal.h:176:
./libavutil/libm.h:121:22: error: static declaration of 'erf' follows non-static declaration
static inline double erf(double z)
^
/home/winixt/emsdk/upstream/emscripten/system/include/libc/math.h:171:13: note: previous declaration is here
double erf(double);
^
In file included from ./libavutil/internal.h:176:
./libavutil/libm.h:340:9: warning: 'isnan' macro redefined [-Wmacro-redefined]
#define isnan(x) \
^
/home/winixt/emsdk/upstream/emscripten/system/include/libc/math.h:66:9: note: previous definition is here
#define isnan(x) ( \
^
In file included from ./libavutil/common.h:533:
In file included from ./libavutil/internal.h:176:
./libavutil/libm.h:359:9: warning: 'isfinite' macro redefined [-Wmacro-redefined]
#define isfinite(x) \
^
/home/winixt/emsdk/upstream/emscripten/system/include/libc/math.h:76:9: note: previous definition is here
#define isfinite(x) ( \
^
In file included from ./libavutil/internal.h:176:
./libavutil/libm.h:366:31: error: static declaration of 'hypot' follows non-static declaration
static inline av_const double hypot(double x, double y)
^
/home/winixt/emsdk/upstream/emscripten/system/include/libc/math.h:223:13: note: previous declaration is here
double hypot(double, double);
^
In file included from ./libavutil/internal.h:176:
./libavutil/libm.h:423:22: error: static declaration of 'rint' follows non-static declaration
static inline double rint(double x)
^
/home/winixt/emsdk/upstream/emscripten/system/include/libc/math.h:307:13: note: previous declaration is here
double rint(double);
^
In file included from ./libavutil/internal.h:176:
./libavutil/libm.h:430:43: error: static declaration of 'lrint' follows non-static declaration
static av_always_inline av_const long int lrint(double x)
^
2 warnings and 12 errors generated.
emcc: error: '/home/winixt/emsdk/upstream/bin/clang -target wasm32-unknown-emscripten -D__EMSCRIPTEN_major__=1 -D__EMSCRIPTEN_minor__=39 -D__EMSCRIPTEN_tiny__=20 -D_LIBCPP_ABI_VERSION=2 -Dunix -D__unix -D__unix__ -Werror=implicit-function-declaration -Xclang -nostdsysteminc -Xclang -isystem/home/winixt/emsdk/upstream/emscripten/system/include/compat -Xclang -isystem/home/winixt/emsdk/upstream/emscripten/system/include -Xclang -isystem/home/winixt/emsdk/upstream/emscripten/system/include/libc -Xclang -isystem/home/winixt/emsdk/upstream/emscripten/system/lib/libc/musl/arch/emscripten -Xclang -isystem/home/winixt/emsdk/upstream/emscripten/system/local/include -Xclang -isystem/home/winixt/emsdk/upstream/emscripten/system/include/SSE -Xclang -isystem/home/winixt/emsdk/upstream/emscripten/system/lib/compiler-rt/include -Xclang -isystem/home/winixt/emsdk/upstream/emscripten/cache/wasm/include -DEMSCRIPTEN -fignore-exceptions -D__EMSCRIPTEN_PTHREADS__=1 -I. -I./ -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -DHAVE_AV_CONFIG_H -DBUILDING_avdevice -std=c11 -fomit-frame-pointer -pthread -g -Wdeclaration-after-statement -Wall -Wdisabled-optimization -Wpointer-arith -Wredundant-decls -Wwrite-strings -Wtype-limits -Wundef -Wmissing-prototypes -Wno-pointer-to-int-cast -Wstrict-prototypes -Wempty-body -Wno-parentheses -Wno-switch -Wno-format-zero-length -Wno-pointer-sign -Wno-unused-const-variable -Wno-bool-operation -Wno-char-subscripts -O3 -fno-math-errno -fno-signed-zeros -mllvm -stack-alignment=16 -mstack-alignment=16 -Qunused-arguments -Werror=implicit-function-declaration -Werror=missing-prototypes -Werror=return-type -MMD -MF libavdevice/alldevices.d -MT libavdevice/alldevices.o -c -pthread -pthread libavdevice/alldevices.c -Xclang -isystem/home/winixt/emsdk/upstream/emscripten/system/include/SDL -c -o libavdevice/alldevices.o -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr' failed (1)
make: *** [ffbuild/common.mak:59: libavdevice/alldevices.o] Error 1
Here is my command :
I tried the unreasonable version of emcc(2.0.1、2.0.0、1.40.1、1.39.20), but encountered the same error。
The official website's docker image is not good either.
emconfigure ./configure \
--disable-x86asm \
--ar=emar \
--cc=emcc \
--cxx=em++ \
--objcc=emcc \
--dep-cc=emcc \
--disable-inline-asm \
--disable-doc \
--disable-stripping
emmake make
Not sure its related to the thread issue that uses the emlibc. It is conflicting the libavutils. You may try to add
--disable-pthreads
and--disable-w32threads
Sincepthread
is detected automatically.