Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with using ffmpeg webport via USE_FFMPEG=1 #4

Open
twadrianlis opened this issue Jan 12, 2024 · 1 comment
Open

Issue with using ffmpeg webport via USE_FFMPEG=1 #4

twadrianlis opened this issue Jan 12, 2024 · 1 comment

Comments

@twadrianlis
Copy link

Hi,

I added ffmpeg to my project. I add USE_FFMPEG=1 flags to compiler and linker (via cmake).

I see ffmpeg correctly downloaded and built in my local .emscripten_cache, in asmjs/port-builds I see ffmpeg directory and all headers as well as libffmpeg-mt.bc

The project builds but during linkage I get unresolved externals errors from avformat library. This is my output:

cmd.exe /C "cd . && C:\emsdk\emscripten-1.39.4.7-windows64\fastcomp\emscripten\em++.bat -DNDEBUG -O2 -O2  -O0 -g3 --source-map-base http://localhost:8000/ -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=2 -s USE_SDL=2 -s USE_BOOST_HEADERS=1 -s WASM=1 -s ASSERTIONS=2 -s DEMANGLE_SUPPORT=1 --bind -s TOTAL_MEMORY=256MB -fexceptions --preload-file ../../wasm_data@/ -lwebsocket.js  --shell-file ../tizen/src/shell_minimal.html -s ENVIRONMENT_MAY_BE_TIZEN -s USE_FFMPEG=1 tizen/wasm/CMakeFiles/illusion-tizen.dir/source/Main.cpp.o -o tizen\wasm\illusion-tizen.html  renderer/libillusion-renderer-common.a  dependencies/spdlog/libspdlog.a  dependencies/freetype/libfreetype.a  dependencies/absl/absl/strings/libabsl_strings.a  dependencies/absl/absl/strings/libabsl_strings_internal.a  dependencies/absl/absl/base/libabsl_base.a  dependencies/absl/absl/base/libabsl_spinlock_wait.a  dependencies/absl/absl/numeric/libabsl_int128.a  dependencies/absl/absl/base/libabsl_throw_delegate.a  dependencies/absl/absl/base/libabsl_raw_logging_internal.a  dependencies/absl/absl/base/libabsl_log_severity.a  _deps/zip-build/libzip.a  lib/libhv_static.a  -lpthread  -lm  -ldl && cd ."
error: undefined symbol: _Z18avio_alloc_contextPhiiPvPFiS0_S_iES2_PFxS0_xiE
warning: To disable errors for undefined symbols use `-s ERROR_ON_UNDEFINED_SYMBOLS=0`
error: undefined symbol: _Z19avformat_open_inputPP15AVFormatContextPKcP13AVInputFormatPP12AVDictionary
error: undefined symbol: _Z22avformat_alloc_contextv
error: undefined symbol: _Z7av_freePv
error: undefined symbol: _Z9av_mallocm
Error: Aborting compilation due to previous errors
shared:ERROR: 'C:/emsdk/emscripten-1.39.4.7-windows64/node/12.9.1_64bit/bin/node.exe C:\emsdk\emscripten-1.39.4.7-windows64\fastcomp\emscripten\src\compiler.js c:\users\dasoft\appdata\local\temp\tmplvuacp.txt' failed (1)
ninja: build stopped: subcommand failed.

I have no ideas left. Clearly it has issues with libffmpeg functions like avformat_open_input, avformat_alloc_context etc.

Any ideas?

@abujalski
Copy link
Contributor

Hi,

It looks that you need to wrap ffmpeg headers with extern "C" like:

extern "C" {
#include <libavcodec/avcodec.h>
}

in all your sources, to avoid C++ function name mangling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants