我正在尝试使用emscripten将一个具有以下开头包含的程序移植到WebAssembly(wasm):
#include <Eigen/Geometry>
#include <boost/filesystem.hpp>
#include <dvo/core/intrinsic_matrix.h>
#include <dvo/core/surface_pyramid.h>
#include <dvo/dense_tracking.h>
#include <fstream>
#include <iostream>
#include <opencv2/opencv.hpp>
为了更容易入门,我尝试编译一个最小的OpenCV "hello world"程序:
#include <opencv2/opencv.hpp>
#include <stdio.h>
using namespace cv;
int main(int argc, char **argv) {
Mat M(2, 2, CV_8UC3, Scalar(0, 0, 255));
std::cout << "M = " << std::endl << " " << M << std::endl;
return 0;
}
我有以下
CMakeLists.txt
文件:cmake_minimum_required(VERSION 2.8)
project( DisplayImage )
find_package( OpenCV REQUIRED PATHS third-party/opencv-4.1.0/build_wasm NO_DEFAULT_PATH)
include_directories( ${OpenCV_INCLUDE_DIRS} )
add_executable( hello hello.cpp )
target_link_libraries( hello ${OpenCV_LIBS} )
third-party/opencv-4.1.0/build_wasm
是我编译 OpenCV 到 wasm 的文件夹(详见文档),使用了以下命令:
python ./platforms/js/build_js.py build_wasm --build_wasm
现在,当我在我的项目上运行emconfigure cmake ..
时,它无法找到OpenCV(“无法找到软件包配置...”)。 我做错了什么,但我不知道是什么。不幸的是,使用cmake和依赖项的emscripten文档并不详细。或者这个问题可能只与OpenCV有关,我不知道。
编辑
完整错误:
~/t/w/w/build emconfigure cmake .. ven. 26 avril 2019 16:01:00 CEST
CMake Error at CMakeLists.txt:5 (find_package):
Could not find a package configuration file provided by "OpenCV" with any
of the following names:
OpenCVConfig.cmake
opencv-config.cmake
Add the installation prefix of "OpenCV" to CMAKE_PREFIX_PATH or set
"OpenCV_DIR" to a directory containing one of the above files. If "OpenCV"
provides a separate development package or SDK, be sure it has been
installed.
-- Configuring incomplete, errors occurred!
See also "/home/matthieu/temp/wasm/wasm-opencv/build/CMakeFiles/CMakeOutput.log".
shared:ERROR: Configure step failed with non-zero return code: 1. Command line: cmake -DCMAKE_CROSSCOMPILING_EMULATOR="/home/matthieu/programs/emsdk/node/8.9.1_64bit/bin/node" .. -DCMAKE_TOOLCHAIN_FILE=/home/matthieu/programs/emsdk/emscripten/1.38.30/cmake/Modules/Platform/Emscripten.cmake at /home/matthieu/temp/wasm/wasm-opencv/build
CMakeFiles/CMakeOutput.log
的内容:
The target system is: Emscripten - 1 - x86
The host system is: Linux - 4.19.36-1-lts - x86_64