使用emcmake的未定义符号(emscripten和opencv)

问题描述 投票:0回答:1

我正在尝试在浏览器中使用OpenCV构建一个简约项目。

我已经在计算机上编译了OpenCV。

这里是C ++代码(josef.cpp):

#include <iostrem>

#include <opencv2/imgcodecs.hpp>
#include <opencv2/opencv.hpp>   

int main(int argc, char **argv) 
{ 
    printf("Hello here\n"); 
    cv::Mat m;
    std::cout << m;
}

这里是CMakeLists.txt

cmake_minimum_required(VERSION 2.8)
project( josef )

# Give here the directory in which we have
# the file OpenCVConfig.cmake
set(OpenCV_DIR "/usr/local/lib/cmake/opencv4")
find_package( OpenCV REQUIRED )
add_executable( josef josef.cpp )
target_link_libraries( josef ${OpenCV_LIBS} )

编译方式

cmake .
make

效果很好,并提供了产生预期结果的可执行文件:

Hello here
[]

尝试使用脚本时出现我的问题。

emcmake cmake .

会产生很多这样的警告:

CMake Warning (dev) at /usr/local/lib/cmake/opencv4/OpenCVModules.cmake:393 (add_library):
  ADD_LIBRARY called with SHARED option but the target platform does not
  support dynamic linking.  Building a STATIC library instead.  This may lead
  to problems.
Call Stack (most recent call first):
  /usr/local/lib/cmake/opencv4/OpenCVConfig.cmake:126 (include)
  CMakeLists.txt:7 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

然后

emmake make

未定义符号失败:

error: undefined symbol: _ZN2cv3Mat10deallocateEv
warning: Link with `-s LLD_REPORT_UNDEFINED` to get more information on undefined symbols
warning: To disable errors for undefined symbols use `-s ERROR_ON_UNDEFINED_SYMBOLS=0`

我的问题是:我错了什么?如何告诉emscripten著名的丢失符号在哪里(如果我正确理解的话,这些是文件.so)?

opencv cmake emscripten undefined-symbol
1个回答
0
投票

这部分是黑客解决方案。

© www.soinside.com 2019 - 2024. All rights reserved.