我正在尝试创建脚本以按照emscirpten的说明进行编译和运行。
这是我希望为其创建cmake文件的命令。
./emcc -std=c++11 -O3 -I.. ~/DLIB/dlib-19.4/dlib/all/source.cpp -I/home/akshay/DLIB/dlib-19.4 -I/usr/include/X11/ -lpthread -lX11 -lopencv_imgcodecs -o webca.js ~/DLIB/dlib-19.4/examples/webcam_face_pose_ex.cpp -ldlib `pkg-config opencv --cflags --libs`
到目前为止,我已经提出了这一点。这是我的CMAKELists.txt文件。
cmake_minimum_required(VERSION 3.5.1)
project(DLIB)
SET(CMAKE_BUILD_TYPE_INIT "Release")
set(CMAKE_CXX_STANDARD 11)
if (${CMAKE_SYSTEM_NAME} MATCHES "Emscripten")
set(CMAKE_C_COMPILER "emcc")
endif ()
if(NOT DEFINED OpenCV_PREFIX)
set(OpenCV_PREFIX ${CMAKE_INSTALL_PREFIX})
endif()
set(CMAKE_VERBOSE_MAKEFILE on)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/build.emscripten)
set(DLIB_SRC "/home/akshay/DLIB/dlib-19.4/examples/webcam_face_pose_ex.cpp")
add_library(DLIB_static ${DLIB_SRC})
set(OpenCV_PREFIX /usr/share/OpenCV/OpenCVConfig.cmake)
include_directories(/usr/include/X11 /home/akshay/DLIB/dlib-19.4 /home/akshay/DLIB/dlib-19.4/dlib/all/source.cpp)
set_target_properties(DLIB_static PROPERTIES LINK_FLAGS "-s DEMANGLE_SUPPORT=1 --preload-file assets --bind")
find_package(PkgConfig REQUIRED)
find_package(OpenCV REQUIRED
PATHS ${OpenCV_PREFIX}/lib/cmake/
${OpenCV_PREFIX}/share/OpenCV/
NO_DEFAULT_PATH)
find_library(OpenCV REQUIRED PATHS ${OpenCV_PREFIX}/lib/cmake/
${OpenCV_PREFIX}/share/OpenCV/
NO_DEFAULT_PATH)
set(CMAKE_REQUIRED_FLAGS "-std=c++11 -O3 -lpthread -lX11 -lopencv_imgcodecs -ldlib `pkg-config opencv --cflags --libs`")
#file(GLOB_RECURSE CORE_HDR src/.h)
#file(GLOB_RECURSE CORE_SRC src/.cpp)
add_definitions("-s DEMANGLE_SUPPORT=1 --preload-file ${CMAKE_SOURCE_DIR}/assets --bind")
add_executable(DLIB /home/akshay/DLIB/dlib-19.4/examples/webcam_face_pose_ex.cpp)
当我运行此命令时:
cmake -DCMAKE_PREFIX_PATH=/usr/share/OpenCV/OpenCVConfig.cmake -DCMAKE_BUILD_TYPE=Debug -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=/home/akshay/Downloads/emsdk-portable/emscripten/1.37.16/cmake/Modules/Platform/Emscripten.cmake . && make
它给我这样的错误:
CMake Error at CMakeLists.txt:25 (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.
似乎无法找到CMAKE_PREFIX_PATH或我没有正确设置它。
从昨天开始,我刚刚开始摆弄CMAKE。我可能对自己所做的事情一无所知。也尝试了其他一些答案。
任何帮助将不胜感激
最佳答案
您只需要将OpenCV_DIR
设置为OpenCV
的安装路径,例如:
cmake -DOpenCV_DIR=/usr/local/share/OpenCV ..
关于opencv - 将OpenCV与cmake链接。将 “OpenCV”的安装前缀添加到CMAKE_PREFIX_PATH不起作用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/45453604/