emscripten-core / emscripten

Emscripten: An LLVM-to-WebAssembly Compiler
Other
25.88k stars 3.32k forks source link

how to compile a cpp file that contains "#include "opencv2/opencv.hpp" into a wasm file? #13994

Open constantvariable1 opened 3 years ago

constantvariable1 commented 3 years ago

Hello,

as the question mentions, that is exactly what I want. I have a cpp file that simply displays a matrix using the MAT class from open cv and because I've included the opencv library in the file I get errors when running emcc -s WASM=1 cvcaller.cpp -o output.js. I read through the forums and found that I need to compile the opencv library into a .a file and then link it with my cpp file. Something like this. em++ -s WASM=1 cvcaller.cpp libopencv.a -o output.js. So I used cmake to build a static library and I got libopencv_world.a. I'm assuming this has all the opencv modules in it.

However when I run the following command I just get the error that "opencv2/opencv.hpp" is not found. em++ -s WASM=1 libopencv_world.a cvcaller.cpp -o output.js

the libopencv_world.a file was created in another machine so could that be the problem?

I am new at this and would really appreciate detailed instructions as to accomplish my objective which is to complile and run the cpp file that references an opencv module in the browser using webassembly.

Thanks.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 30 days. Feel free to re-open at any time if this issue is still relevant.