Skip to content

OpenCV compilation errors #490

Open
Open
@Brennanzuz

Description

@Brennanzuz

Hi I am trying to compile the OpenCV source code (with the contrib modules) using WASI-SDK, as I was told by this issue that emscripten could not handle wasmtime (???).

So after following all the instructions of:

git clone --recursive https://github.com/WebAssembly/wasi-sdk.git
cd wasi-sdk/
git submodule update --init
cmake -G Ninja -B build/toolchain -S . -DWASI_SDK_BUILD_TOOLCHAIN=ON -DCMAKE_INSTALL_PREFIX=build/install
cmake --build build/toolchain --target install
cmake -G Ninja -B build/sysroot -S . -DCMAKE_INSTALL_PREFIX=build/install -DCMAKE_TOOLCHAIN_FILE=build/install/share/cmake/wasi-sdk.cmake -DCMAKE_C_COMPILER_WORKS=ON -DCMAKE_CXX_COMPILER_WORKS=ON
cmake --build build/sysroot --target install

to install this SDK, and then going to my ~ folder where my opencv and opencv_contrib repos are at and doing:

cmake -DCMAKE_TOOLCHAIN_FILE=~/wasi-sdk/build/install/share/cmake/wasi-sdk.cmake -DOPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modules ../opencv

It gave me the following error:

CMake Error at /home/neonu/.local/lib/python3.10/site-packages/cmake/data/share/cmake-3.27/Modules/CMakeTestCXXCompiler.cmake:60 (message):
  The C++ compiler

    "/home/neonu/wasi-sdk/build/install/share/cmake/../..//bin/clang++"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: '/home/neonu/build/CMakeFiles/CMakeScratch/TryCompile-99YUeW'
    
    Run Build Command(s): /home/neonu/.local/lib/python3.10/site-packages/cmake/data/bin/cmake -E env VERBOSE=1 /usr/bin/gmake -f Makefile cmTC_df402/fast
    /usr/bin/gmake  -f CMakeFiles/cmTC_df402.dir/build.make CMakeFiles/cmTC_df402.dir/build
    gmake[1]: Entering directory '/home/neonu/build/CMakeFiles/CMakeScratch/TryCompile-99YUeW'
    Building CXX object CMakeFiles/cmTC_df402.dir/testCXXCompiler.cxx.obj
    /home/neonu/wasi-sdk/build/install/share/cmake/../..//bin/clang++ --target=wasm32-wasi-threads   -pthread  -fPIE -MD -MT CMakeFiles/cmTC_df402.dir/testCXXCompiler.cxx.obj -MF CMakeFiles/cmTC_df402.dir/testCXXCompiler.cxx.obj.d -o CMakeFiles/cmTC_df402.dir/testCXXCompiler.cxx.obj -c /home/neonu/build/CMakeFiles/CMakeScratch/TryCompile-99YUeW/testCXXCompiler.cxx
    Linking CXX executable cmTC_df402
    /home/neonu/.local/lib/python3.10/site-packages/cmake/data/bin/cmake -E cmake_link_script CMakeFiles/cmTC_df402.dir/link.txt --verbose=1
    /home/neonu/wasi-sdk/build/install/share/cmake/../..//bin/clang++ --target=wasm32-wasi-threads  -pthread   -Wl,--import-memory -Wl,--export-memory  CMakeFiles/cmTC_df402.dir/testCXXCompiler.cxx.obj -o cmTC_df402 
    wasm-ld: error: cannot open /home/neonu/wasi-sdk/build/install/lib/clang/18/lib/wasi/libclang_rt.builtins-wasm32.a: No such file or directory
    clang++: error: linker command failed with exit code 1 (use -v to see invocation)
    gmake[1]: *** [CMakeFiles/cmTC_df402.dir/build.make:100: cmTC_df402] Error 1
    gmake[1]: Leaving directory '/home/neonu/build/CMakeFiles/CMakeScratch/TryCompile-99YUeW'
    gmake: *** [Makefile:127: cmTC_df402/fast] Error 2
    
    

  

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:130 (project)


-- Configuring incomplete, errors occurred!

I was hoping that integrating this SDK with a tried and true repository like OpenCV would be exemplary to see how this works.

I am on an Ubuntu 22.04 system. Ask me if you need any other information.

What should I do?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions