Skip to content

build FFmpeg got the ERROR:emcc is unable to create an executable file.C compiler test failed. #21070

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

Open
stark-jarvis opened this issue Jan 12, 2024 · 9 comments

Comments

@stark-jarvis
Copy link

Please include the following in your bug report:

Version of emscripten/emsdk:
Please include the output emcc -v here
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.51 (c0c2ca1)
clang version 18.0.0git (https://github.com/llvm/llvm-project f2464ca317bfeeedddb7cbdea3c2c8ec487890bb)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /data/download/emsdk-lib/emsdk/upstream/bin

Failing command line in full:
If this is compile or link-time failure please include the full failing command
along with its entire output.

configure: ./configure --cc=emcc --cxx=em++ --ar=emar --nm=emnm --ranlib=emranlib --prefix=/data/site/wasm/ffmpeg/ffmpeg-lib --enable-cross-compile --target-os=none --arch=x86_64 --cpu=generic --enable-gpl --enable-version3 --disable-sdl2 --disable-iconv --disable-runtime-cpudetect --disable-cuda-llvm --disable-programs --disable-doc --disable-avdevice --disable-swresample --disable-swscale --disable-postproc --disable-avformat --disable-avfilter --disable-everything --disable-debug --disable-asm --disable-fast-unaligned --disable-network --enable-parser=hevc --enable-decoder=hevc
emcc is unable to create an executable file.
C compiler test failed.

use emcc build my "C" demo, is OK....what`s wrong ???

FFmpeg was builded success. see the next info:

ffmpeg version N-113275-g1081bae94d Copyright (c) 2000-2024 the FFmpeg developers
built with gcc 11 (GCC)
configuration: --prefix=/root/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/root/ffmpeg_build/include --extra-ldflags=-L/root/ffmpeg_build/lib --extra-libs=-lpthread --extra-libs=-lm --bindir=/root/bin --enable-gpl --enable-libfdk_aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree
libavutil 58. 36.101 / 58. 36.101
libavcodec 60. 37.100 / 60. 37.100
libavformat 60. 20.100 / 60. 20.100
libavdevice 60. 4.100 / 60. 4.100
libavfilter 9. 17.100 / 9. 17.100
libswscale 7. 6.100 / 7. 6.100
libswresample 4. 13.100 / 4. 13.100
libpostproc 57. 4.100 / 57. 4.100

@sbc100
Copy link
Collaborator

sbc100 commented Jan 12, 2024

Often the ./configure script will write an error log somewhere when things go wrong. Can you find that log and perhaps attach it to this bug?

Have you tried running ./configure with emconfigure?

@RightFS
Copy link

RightFS commented Jan 24, 2024

emconfigure ./configure --cc="emcc" --cxx="em++" --ar="emar" --prefix=/usr/local/decoder_wasm/ffmpeg --enable-cross-compile --target-os=none --arch=x86_32 --cpu=generic \
    --enable-gpl --enable-version3 --disable-avdevice --enable-avformat --disable-swresample --disable-postproc --disable-avfilter \

    --disable-programs --disable-everything \
    --disable-ffplay --disable-ffprobe --disable-asm --disable-doc --disable-devices --disable-network \
    --disable-hwaccels --enable-parsers --disable-bsfs --disable-debug --disable-protocols --disable-indevs --disable-outdevs \     
    --enable-demuxers \
    --enable-decoder=hevc --enable-parser=hevc \
    --enable-decoder=h264  --enable-parser=h264
configure: ./configure --cc=emcc --cxx=em++ --ar=emar --prefix=/usr/local/decoder_wasm/ffmpeg --enable-cross-compile --target-os=none --arch=x86_32 --cpu=generic --enable-gpl --enable-version3 --disable-avdevice --enable-avformat --disable-swresample --disable-postproc --disable-avfilter --disable-programs --disable-everything --disable-ffplay --disable-ffprobe --disable-asm --disable-doc --disable-devices --disable-network --disable-hwaccels --enable-parsers --disable-bsfs --disable-debug --disable-protocols --disable-indevs --disable-outdevs --enable-demuxers --enable-decoder=hevc --enable-parser=hevc --enable-decoder=h264 --enable-parser=h264       
emcc is unable to create an executable file.
C compiler test failed.

If you think configure made a mistake, make sure you are using the latest
version from Git.  If the latest version fails, report the problem to the
ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.libera.chat.
Include the log file "ffbuild/config.log" produced by configure as this will help
solve the problem.
emconfigure: error: './configure --cc=emcc --cxx=em++ --ar=emar --prefix=/usr/local/decoder_wasm/ffmpeg --enable-cross-compile --target-os=none --arch=x86_32 --cpu=generic --enable-gpl --enable-version3 --disable-avdevice --enable-avformat --disable-swresample --disable-postproc --disable-avfilter --disable-programs --disable-everything --disable-ffplay --disable-ffprobe --disable-asm --disable-doc --disable-devices --disable-network --disable-hwaccels --enable-parsers --disable-bsfs --disable-debug --disable-protocols --disable-indevs --disable-outdevs --enable-demuxers --enable-decoder=hevc --enable-parser=hevc --enable-decoder=h264 --enable-parser=h264' failed (returned 1)

same error here
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.52 (fa47840)
Copyright (C) 2014 the Emscripten authors (see AUTHORS.txt)
This is free and open source software under the MIT license.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

@RightFS
Copy link

RightFS commented Jan 24, 2024

emcc -nologo -c -Fo/tmp/ffconf.UXpKlb94/test.o /tmp/ffconf.UXpKlb94/test.c
clang: error: unknown argument: '-nologo'

@sbc100
Copy link
Collaborator

sbc100 commented Jan 24, 2024

You need to figure out why -nologo is being added. That is a windows-only flag and should not be passed to emcc.

@chulsu72
Copy link

I removed all -nologo from ffmpeg's configure file and built it.
wasm-ld: error: unknown file type: /tmp/ffconf.afyrIvzC/test.o

Ubuntu 20.04.6 LTS (WSL2)
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.52
ffmpeg 4.4 or 6.1

$ cat ffbuild/config.log
...
BEGIN /tmp/ffconf.afyrIvzC/test.c
1 int main(void){ return 0; }
END /tmp/ffconf.afyrIvzC/test.c
emcc -c -Fo/tmp/ffconf.afyrIvzC/test.o /tmp/ffconf.afyrIvzC/test.c
emcc -Fe/tmp/ffconf.afyrIvzC/test /tmp/ffconf.afyrIvzC/test.o
wasm-ld: error: unknown file type: /tmp/ffconf.afyrIvzC/test.o
...
C compiler test failed.

@sbc100
Copy link
Collaborator

sbc100 commented Jan 27, 2024

That seems very odd since it looks like /tmp/ffconf.afyrIvzC/test.o was just compiled with emcc. Normally wasm-ld: error: unknown file type means that file is some other kind of object file, normally one build for the host OS, e.g. an ELF file.

You can always run file /tmp/ffconf.afyrIvzC/test.o to find out what type of file it really is.

@kashiken
Copy link

kashiken commented Feb 4, 2024

Hello,
Let me jump in this thread and share my idea.

I faced the same problem with the following environment:

  • Ubuntu 22.04.3 LTS on WSL2
  • emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.51
  • ffmpeg 4.3.2

When I ran the following command in the ffmpeg-4.3.2 directory,
emconfigure ./configure (options)
the script was aborted and the following message appeared, as others had mentioned,
emcc is unable to create an executable file.

I checked ffbuild/config.log and investigate the problem:

  1. clang: error: unknown argument: '-nologo'
    -> This error comes because emcc doesn't have the option.
    Removing '-nologo' from configure resolves but another error occurs.
  2. wasm-ld: error: unknown file type: /tmp/ffconf.(random)/test.o
    -> I found that test.o in the directory has 0 byte, it means the compiler doesn't make object file correctly.
    I digged this and find that the configure script execute following command but emcc dosn't support the option '-Fo' .
    emcc -O3 -I/opt/ffmpeg/include -I/opt/ffmpeg/include/opus -c -Fo/tmp/ffconf.(random)/test.o /tmp/ffconf.(random)/test.c
    The correct option to specify output object for emcc is '-o'.

Both of the wrong options are for Microsoft MSVC, so I conclude the root cause of the problem is wrong compiler judgement written in probe_cc().
Actually I don't know what is the correct operation of compiler judgement but commenting out 'elif' section below this line helps to run configure to the end.
elif $_cc -nologo- 2>&1 | grep -q Microsoft || { $_cc -v 2>&1 | grep -q clang && $_cc -? > /dev/null 2>&1; }; then

This is a problem with the configure script, not with emcc, so I believe this should be discussed in the ffmpeg repository.

@chulsu72
Copy link

chulsu72 commented Feb 4, 2024

I did as kashiken said.

The build was successful by changing to the following environment:

Ubuntu 20.04.6 LTS (WSL2)
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.40
ffmpeg 4.4

I believe this should be discussed in the ffmpeg repository too.

Thank you very much.

@jozefchutka
Copy link

jozefchutka commented May 31, 2024

Please join our discussion related to ffmpeg build on the most recent emscripten on #22008

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

6 participants