OpenCV Build JS Fails on MacOS

asked 2020-10-12 14:04:32 -0600

I am trying to compile OpenCV for the web (JavaScript). I have set everything up, however, I keep running into this issue where I would run the following command:

$ sudo python3 ./platforms/js/build_js.py build_wasm --build_wasm  --emscripten_dir /Users/erdesign7/emsdk/upstream/emscripten

and I would keep getting this error

Re-run cmake no build system arguments
-- OpenCV: system-specific configuration file is not found: 'Emscripten'
-- Detected processor: x86
-- Looking for ccache - not found
CMake Error at cmake/OpenCVCompilerOptimizations.cmake:593 (message):
  Compiler doesn't support baseline optimization flags:
Call Stack (most recent call first):
  cmake/OpenCVCompilerOptions.cmake:296 (ocv_compiler_optimization_options)
  CMakeLists.txt:610 (include)


-- Configuring incomplete, errors occurred!
See also "/Users/erdesign7/Desktop/Software/grab_cut_frontend/opencv/build_wasm/CMakeFiles/CMakeOutput.log".
See also "/Users/erdesign7/Desktop/Software/grab_cut_frontend/opencv/build_wasm/CMakeFiles/CMakeError.log".
Traceback (most recent call last):
  File "./platforms/js/build_js.py", line 269, in <module>
    builder.config()
  File "./platforms/js/build_js.py", line 192, 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

I went to line 296 in the file OpenCVCompilerOptions.cmake and this was the following code

  294  include(cmake/OpenCVCompilerOptimizations.cmake)
  295  if(COMMAND ocv_compiler_optimization_options)
  296   ocv_compiler_optimization_options()
  297  endif()
  298  if(COMMAND ocv_compiler_optimization_options_finalize)
  299    ocv_compiler_optimization_options_finalize()
  300  endif()

And all I did was comment out line 296 and VIOALA the compilation worked and it finished.

 294  include(cmake/OpenCVCompilerOptimizations.cmake)
 295  if(COMMAND ocv_compiler_optimization_options)
 296   # I COMMENTED OUT THIS LINE ocv_compiler_optimization_options()
 297  endif()
 298  if(COMMAND ocv_compiler_optimization_options_finalize)
 299    ocv_compiler_optimization_options_finalize()
 300  endif()

Why does that function create that error and how can I compile successfully on a Mac with the compiler optimization flags???

Can someone please explain??

Thank you in advance.

edit retag flag offensive close merge delete