Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problem in compilation of C++ code to Wasm using emcc

I am trying to compile the C++ code to Wasm but facing problems in it. My C++ code included dlib and OpenCV libraries. I have successfully compiled OpenCV and dlib for C++ environment. Also, I have installed emscripten in my system.

The directory structure is

C Drive

|..

|-- dlib

|-- emsdk

|-- opencv

|-- cpp_project

now when I am inside the cpp_project dir in command prompt (open in admin mode) I am executing the following command.

emcc -msse3 -msimd128 -std=c++11 -O3 -I ../dlib ../opencv/build/include/opencv2/core.hpp ../dlib/dlib/all/source.cpp -lstdc++ -lpthread -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4 -s TOTAL_MEMORY=1024MB -s "EXTRA_EXPORTED_RUNTIME_METHODS=['ccall', 'cwrap']" -s WASM=1 -o main.js

I am getting the following error:

../opencv/build/include/opencv2/core.hpp:52:10: fatal error: 'opencv2/core/cvdef.h' file not found

#include "opencv2/core/cvdef.h" ^~~~~~~~~~~~~~~~~~~~~~ 1 error generated.

Please help me.

like image 763
Mayank Tiwari Avatar asked Sep 18 '25 05:09

Mayank Tiwari


1 Answers

You have to change -I ../dlib ../opencv/build/include/opencv2/core.hpp to -I ../dlib -I ../opencv/build/include

like image 83
JCWasmx86 Avatar answered Sep 19 '25 19:09

JCWasmx86