Makogan
Makogan

Reputation: 9538

Building OpenCV.js fails. CMake can't find installed compilers?

I have the following directory structure:

~/emsdk
~/opencv

I am trying to build OpenCV.js

I do

cd ~/opencv
python ./platforms/js/build_js.py build_js --emscripten_dir=~/emsdk/

Which results in:

CMake Error at /usr/share/cmake-3.10/Modules/CMakeDetermineSystem.cmake:100 (message):
  Could not find toolchain file:
  ~/emsdk/cmake/Modules/Platform/Emscripten.cmake
Call Stack (most recent call first):
  CMakeLists.txt:135 (project)


CMake Error: CMake was unable to find a build program corresponding to "Unix Makefiles".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
Traceback (most recent call last):
  File "./platforms/js/build_js.py", line 227, in <module>
    builder.config()
  File "./platforms/js/build_js.py", line 167, in config
    execute(cmd)
  File "./platforms/js/build_js.py", line 23, in execute
    raise Fail("Child returned: %s" % retcode)
__main__.Fail: Child returned: 1

Both gcc and g++ are installed in the system. Prior of running this I went to ~/emsdk and ran:

./emsdk update
./emsdk install latest
./emsdk activate latest
source ./emsdk_env.sh

I am not sure why this is failing. I am trying to follow this [tutorial][1].

EDIT:

I am doing this on Ubuntu, if it helps

EDIT 2:

It seems an important part of the problem comes from the message:

 CMake Error at /usr/share/cmake-3.10/Modules/CMakeDetermineSystem.cmake:100 (message):
      Could not find toolchain file:
      ~/emsdk/cmake/Modules/Platform/Emscripten.cmake

There is no emsdk/cmake directory.

EDIT 3:

Posting answer, it was the path

Upvotes: 5

Views: 9140

Answers (3)

Take It Easy
Take It Easy

Reputation: 17

On MACOSX:

It works:

python /path-to/opencv-src/platforms/js/build_js.py /path-to/build_js --emscripten_dir=/path-to/emsdk/upstream/emscripten

Note:

  • Important: --emscripten_dir=/path-to/emsdk/upstream/emscripten
  • build_js: let create a empty folder

Thanks All.

Upvotes: 2

Cecil Lew
Cecil Lew

Reputation: 69

For me, this works: python ./platforms/js/build_js.py build_js --emscripten_dir=/home/username/emsdk/upstream/emscripten

Upvotes: 4

Makogan
Makogan

Reputation: 9538

The problem is a stupid assumption on my end. Writing:

python ./platforms/js/build_js.py build_js --emscripten_dir=~/emsdk/

Is the wrong command, the correct one is:

python ./platforms/js/build_js.py build_js --emscripten_dir=/home/username/emsdk/emscripten/1.38.30/

Upvotes: 5

Related Questions