WebAssembly: Undefined Symbol _ZN2cv12VideoCaptureC1Ev while compiling OpenCV C++ code



  • I'm trying to compile my C++ code that uses VideoCapture of OpenCV. Basically I'm trying to display frames of rtsp,rtmp camera within a browser without using a media server. Here are the build modules enabled while compiling OpenCV for emscripten

    cmd = ["cmake",
    "-DCMAKE_BUILD_TYPE=Release",
    "-DCMAKE_TOOLCHAIN_FILE='%s'" % self.get_toolchain_file(),
    "-DCPU_BASELINE=''",
    "-DCPU_DISPATCH=''",
    "-DCV_TRACE=OFF",
    "-DBUILD_SHARED_LIBS=OFF",
    "-DWITH_1394=OFF",
    "-DWITH_ADE=OFF",
    "-DWITH_VTK=OFF",
    "-DWITH_EIGEN=OFF",
    "-DWITH_FFMPEG=ON",
    "-DWITH_GSTREAMER=ON",
    "-DWITH_GTK=ON",
    "-DWITH_GTK_2_X=ON",
    "-DWITH_IPP=OFF",
    "-DWITH_JASPER=OFF",
    "-DWITH_JPEG=ON",
    "-DWITH_WEBP=OFF",
    "-DWITH_OPENEXR=OFF",
    "-DWITH_OPENGL=OFF",
    "-DWITH_OPENVX=OFF",
    "-DWITH_OPENNI=OFF",
    "-DWITH_OPENNI2=OFF",
    "-DWITH_PNG=ON",
    "-DWITH_TBB=OFF",
    "-DWITH_PTHREADS_PF=OFF",
    "-DWITH_TIFF=ON",
    "-DWITH_V4L=ON",
    "-DWITH_OPENCL=ON",
    "-DWITH_OPENCL_SVM=ON",
    "-DWITH_OPENCLAMDFFT=ON",
    "-DWITH_OPENCLAMDBLAS=ON",
    "-DWITH_GPHOTO2=ON",
    "-DWITH_LAPACK=ON",
    "-DWITH_ITT=ON",
    "-DWITH_QUIRC=ON",
    "-DBUILD_ZLIB=ON",
    "-DBUILD_opencv_apps=ON",
    "-DBUILD_opencv_calib3d=ON",
    "-DBUILD_opencv_dnn=ON",
    "-DBUILD_opencv_features2d=ON",
    "-DBUILD_opencv_flann=ON", # No bindings provided. This module is used as a dependency for other modules.
    "-DBUILD_opencv_gapi=ON",
    "-DBUILD_opencv_ml=ON",
    "-DBUILD_opencv_photo=ON",
    "-DBUILD_opencv_imgcodecs=ON",
    "-DBUILD_opencv_shape=ON",
    "-DBUILD_opencv_videoio=ON",
    "-DBUILD_opencv_videostab=ON",
    "-DBUILD_opencv_highgui=ON",
    "-DBUILD_opencv_superres=ON",
    "-DBUILD_opencv_stitching=ON",
    "-DBUILD_opencv_java=OFF",
    "-DBUILD_opencv_java_bindings_generator=OFF",
    "-DBUILD_opencv_js=ON",
    "-DBUILD_opencv_python2=OFF",
    "-DBUILD_opencv_python3=OFF",
    "-DBUILD_opencv_python_bindings_generator=OFF",
    "-DBUILD_EXAMPLES=OFF",
    "-DBUILD_PACKAGE=OFF",
    "-DBUILD_TESTS=OFF",
    "-DBUILD_PERF_TESTS=OFF"]
    

    The error message I get is,

    error: undefined symbol: _ZN2cv12VideoCaptureC1Ev warning: To disable errors for undefined symbols use -s ERROR_ON_UNDEFINED_SYMBOLS=0 error: undefined symbol: _ZN2cv12VideoCaptureD1Ev
    
    #include <emscripten/bind.h>
    #include <emscripten/val.h>
    #include <opencv2/core/mat.hpp>
    #include <opencv2/imgcodecs.hpp>
    #include <opencv2/opencv.hpp>
    #include <opencv2/objdetect.hpp>
    #include <opencv2/highgui.hpp>
    #include <opencv2/imgproc.hpp>
    #include <opencv2/videoio.hpp>
    #include <iostream>
    #include <unistd.h>
    #include <string.h>
    #include <stdio.h>
    

    Here is a list of Header files that I'm using in my program


guest-login-reply
 

A community for developers looking to put WebAssembly to use today. Come rock WebAssembly with us!