Are Build OpenCV.js docs outdated? Failed build from Source

I’ve followed the instructions, but received an error.

emcmake sh -c 'echo ${EMSCRIPTEN}'

configure: sh -c "echo ${EMSCRIPTEN}" -DCMAKE_TOOLCHAIN_FILE=/Users/rose/dev/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DCMAKE_CROSSCOMPILING_EMULATOR=/Users/rose/dev/emsdk/node/14.18.2_64bit/bin/node;--experimental-wasm-bulk-memory;--experimental-wasm-threads

Does anybody have idea how to fix it?

I’ve installed dependencies: node, python, emsdk, cmake and pkg-config

also for command ./emsdk install 2.0.10

Installing tool 'releases-37fc7647c754ac9a28ad588c143b82286de0ef71-64bit'..
Error: Downloading URL 'https://storage.googleapis.com/webassembly/emscripten-releases-builds/mac/37fc7647c754ac9a28ad588c143b82286de0ef71/wasm-binaries-arm64.tbz2': HTTP Error 404: Not Found
error: installation failed!

Previous turns were on my macOS laptop (Air with M2 Apple Silicon)

Now, I’ve tried on Windows PC.
I installed emsdk an hour ago, it success for 2.0.10 ver.

But I’ve got an error.

I have no idea what’s wrong…
Some strings from my CMakeError.log:

Compilation failed:
    source file: 'D:/work/build_js/CMakeFiles/CMakeTmp/src.cxx'
    check option: '  -fsigned-char'
===== BUILD LOG =====
Change Dir: D:/work/build_js/CMakeFiles/CMakeTmp

Run Build Command(s):C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/MSBuild/Current/Bin/amd64/MSBuild.exe cmTC_05b3c.vcxproj /p:Configuration=Release /p:Platform=x64 /p:VisualStudioVersion=17.0 /v:m && MSBuild version 17.3.1+2badb37d1 for .NET Framework

  Microsoft (R) C/C++ Optimizing Compiler Version 19.33.31630 for x64

  USE_PTHREADS=0

  Copyright (C) Microsoft Corporation.  All rights reserved.

  cl /c /W1 /WX- /diagnostics:column /O2 /D _MBCS /D NDEBUG /D "CMAKE_INTDIR=\"Release\"" /Gm- /MD /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"cmTC_05b3c.dir\Release\\" /Fd"cmTC_05b3c.dir\Release\vc143.pdb" /external:W1 /Gd /TP /errorReport:queue  -s USE_PTHREADS=0 -std=c++11 -fsigned-char D:\work\build_js\CMakeFiles\CMakeTmp\src.cxx

cl : command line  warning D9002: ignoring unknown option '-s' [D:\work\build_js\CMakeFiles\CMakeTmp\cmTC_05b3c.vcxproj]

cl : command line  warning D9002: ignoring unknown option '-std=c++11' [D:\work\build_js\CMakeFiles\CMakeTmp\cmTC_05b3c.vcxproj]

cl : command line  warning D9002: ignoring unknown option '-fsigned-char' [D:\work\build_js\CMakeFiles\CMakeTmp\cmTC_05b3c.vcxproj]

c1xx : fatal  error C1083: Cannot open source file: 'USE_PTHREADS=0': No such file or directory [D:\work\build_js\CMakeFiles\CMakeTmp\cmTC_05b3c.vcxproj]

  src.cxx

  Generating Code...



===== END =====

Compilation failed:
    source file: 'D:/work/build_js/CMakeFiles/CMakeTmp/src.c'
    check option: '  -fsigned-char'
===== BUILD LOG =====
Change Dir: D:/work/build_js/CMakeFiles/CMakeTmp

Run Build Command(s):C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/MSBuild/Current/Bin/amd64/MSBuild.exe cmTC_b8788.vcxproj /p:Configuration=Release /p:Platform=x64 /p:VisualStudioVersion=17.0 /v:m && MSBuild version 17.3.1+2badb37d1 for .NET Framework

  Microsoft (R) C/C++ Optimizing Compiler Version 19.33.31630 for x64

  USE_PTHREADS=0

c1 : fatal  error C1083: Cannot open source file: 'USE_PTHREADS=0': No such file or directory [D:\work\build_js\CMakeFiles\CMakeTmp\cmTC_b8788.vcxproj]

  src.c

  Copyright (C) Microsoft Corporation.  All rights reserved.

  cl /c /W1 /WX- /diagnostics:column /O2 /D _MBCS /D NDEBUG /D "CMAKE_INTDIR=\"Release\"" /Gm- /MD /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"cmTC_b8788.dir\Release\\" /Fd"cmTC_b8788.dir\Release\vc143.pdb" /external:W1 /Gd /TC /errorReport:queue  -s USE_PTHREADS=0 -fsigned-char D:\work\build_js\CMakeFiles\CMakeTmp\src.c

cl : command line  warning D9002: ignoring unknown option '-s' [D:\work\build_js\CMakeFiles\CMakeTmp\cmTC_b8788.vcxproj]

cl : command line  warning D9002: ignoring unknown option '-fsigned-char' [D:\work\build_js\CMakeFiles\CMakeTmp\cmTC_b8788.vcxproj]

  Generating Code...



===== END =====

Compilation failed:
    source file: 'D:/work/build_js/CMakeFiles/CMakeTmp/src.cxx'
    check option: '  -W'
===== BUILD LOG =====
Change Dir: D:/work/build_js/CMakeFiles/CMakeTmp

Run Build Command(s):C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/MSBuild/Current/Bin/amd64/MSBuild.exe cmTC_a3996.vcxproj /p:Configuration=Release /p:Platform=x64 /p:VisualStudioVersion=17.0 /v:m && MSBuild version 17.3.1+2badb37d1 for .NET Framework

  Microsoft (R) C/C++ Optimizing Compiler Version 19.33.31630 for x64

  Copyright (C) Microsoft Corporation.  All rights reserved.

  cl /c /W1 /WX- /diagnostics:column /O2 /D _MBCS /D NDEBUG /D "CMAKE_INTDIR=\"Release\"" /Gm- /MD /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"cmTC_a3996.dir\Release\\" /Fd"cmTC_a3996.dir\Release\vc143.pdb" /external:W1 /Gd /TP /errorReport:queue  -s USE_PTHREADS=0 -std=c++11 -W D:\work\build_js\CMakeFiles\CMakeTmp\src.cxx

cl : command line  error D8021: invalid numeric argument '/WD:\work\build_js\CMakeFiles\CMakeTmp\src.cxx' [D:\work\build_js\CMakeFiles\CMakeTmp\cmTC_a3996.vcxproj]



===== END =====

Compilation failed:
    source file: 'D:/work/build_js/CMakeFiles/CMakeTmp/src.c'
    check option: '  -W'
===== BUILD LOG =====
Change Dir: D:/work/build_js/CMakeFiles/CMakeTmp

Run Build Command(s):C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/MSBuild/Current/Bin/amd64/MSBuild.exe cmTC_e6a5e.vcxproj /p:Configuration=Release /p:Platform=x64 /p:VisualStudioVersion=17.0 /v:m && MSBuild version 17.3.1+2badb37d1 for .NET Framework

  Microsoft (R) C/C++ Optimizing Compiler Version 19.33.31630 for x64

  Copyright (C) Microsoft Corporation.  All rights reserved.

  cl /c /W1 /WX- /diagnostics:column /O2 /D _MBCS /D NDEBUG /D "CMAKE_INTDIR=\"Release\"" /Gm- /MD /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"cmTC_e6a5e.dir\Release\\" /Fd"cmTC_e6a5e.dir\Release\vc143.pdb" /external:W1 /Gd /TC /errorReport:queue  -s USE_PTHREADS=0 -W D:\work\build_js\CMakeFiles\CMakeTmp\src.c

cl : command line  error D8021: invalid numeric argument '/WD:\work\build_js\CMakeFiles\CMakeTmp\src.c' [D:\work\build_js\CMakeFiles\CMakeTmp\cmTC_e6a5e.vcxproj]



===== END =====

Hi, just registering my interest in finding a solution to this, it’s bugging me too. I’m running windows 10, finally get to building by using:
python C:/Users/olive/Desktop/Vizn/opencv/opencv4/platforms/js/build_js.py C:/Users/olive/Desktop/Vizn/opencv/opencv4/build_js --emscripten_dir C:/Users/olive/Desktop/emscripten-main/emsdk/upstream/emscripten

But I get the same error as you did.
Anyone know a fix?

1 Like

thanks!
build is passed with command

python3 opencv/platforms/js/build_js.py ./opencv-js --build_wasm --emscripten_dir=/Users/rose/dev/emsdk/upstream/emscripten
1 Like