我正在尝试在浏览器中使用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
[]
我的问题是在尝试使用emscripten时出现的。
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
文件)?
发布于 2020-04-29 13:11:58
这在一定程度上是一种黑客解决方案。
/usr/local/lib/cmake/opencv4/OpenCVModules.cmake
中,将"SHARED“的每个实例更改为”STATIC“。cmake
文件中,添加行file( GLOB opencv_js "/path/to/opencvjs/opencv/build_js/lib/*.a")
本部分假设您手动编译了opencv。
cv::imdecode
.)https://stackoverflow.com/questions/61442822
复制相似问题