When I'm trying to convert OpenCV4.1 program to wasm with the following command an error occured:
sudo /home/xxx/Documents/emsdk/upstream/emscripten/em++ -std=c++11 -s WASM=1 -I ../../../../usr/local/include/opencv4/ test.cpp -o test.html
The following error is coming:
error: undefined symbol: _ZN2cv11namedWindowERKNSt3__212basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEEi
warning: To disable errors for undefined symbols use `-s ERROR_ON_UNDEFINED_SYMBOLS=0`
error: undefined symbol: _ZN2cv13destroyWindowERKNSt3__212basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE
error: undefined symbol: _ZN2cv3Mat10deallocateEv
error: undefined symbol: _ZN2cv6imreadERKNSt3__212basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEEi
error: undefined symbol: _ZN2cv6imshowERKNSt3__212basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEERKNS_11_InputArrayE
error: undefined symbol: _ZN2cv7waitKeyEi
error: undefined symbol: _ZN2cv8fastFreeEPv
Error: Aborting compilation due to previous errors
shared:ERROR: '/home/kaushal/Documents/emsdk/node/12.9.1_64bit/bin/node /home/kaushal/Documents/emsdk/upstream/emscripten/src/compiler.js /tmp/tmpxI4v0X.txt' failed (1)
Simple test code:
#include <opencv2/opencv.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main(int argc, char** argv)
{
Mat image = imread("./1.png");
// Check for failure
if (image.empty())
{
cout << "Could not open or find the image" << endl;
cin.get();
return -1;
}
String windowName = "test";
namedWindow(windowName);
imshow(windowName, image);
waitKey(0);
destroyWindow(windowName);
return 0;
}
Please help me if anyone has any ideas.