模块 opencv_sfm 已禁用,因为未找到以下依赖项:Glog/Gflags - 均已检测到
Module opencv_sfm disabled because the following dependencies are not found: Glog/Gflags - both are detected
我无法使用 cmake 为 opencv 编译 sfm 模块。
如下日志显示cmake同时找到了glog和gflags,但是编译失败
Glog: YES
freetype2: NO
harfbuzz: NO
Julia not found. Not compiling Julia Bindings.
Module opencv_ovis disabled because OGRE3D was not found
No preference for use of exported gflags CMake configuration set, and no hints for include/library directories provided. Defaulting to preferring an installed/exported gflags CMake configuration if available.
Found installed version of gflags: D:/ceres/gflags/out/build/x64-Debug
Detected gflags version: 2.2.2
WARNING: Target "cmTC_9b54b" requests linking to directory "D:/ceres/glog/out/build/x64-Debug". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "cmTC_9b54b" requests linking to directory "D:/ceres/glog/out/build/x64-Debug". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "cmTC_9b54b" requests linking to directory "D:/ceres/glog/out/build/x64-Debug". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "cmTC_9b54b" requests linking to directory "D:/ceres/glog/out/build/x64-Debug". Targets may link only to libraries. CMake is dropping the item.
Checking SFM deps... FALSE
Module opencv_sfm disabled because the following dependencies are not found: Glog/Gflags
Tesseract: NO
Allocator metrics storage type: 'long long'
Registering hook 'INIT_MODULE_SOURCES_opencv_dnn': D:/opencv-4.5.0/modules/dnn/cmake/hooks/INIT_MODULE_SOURCES_opencv_dnn.cmake
opencv_dnn: filter out cuda4dnn source code
CMake Warning at D:/opencv-4.5.0/cmake/OpenCVModule.cmake:679 (message):
Unexpected include: D:/opencv-4.5.0/build/downloads/xfeatures2d
(module=opencv_xfeatures2d)
Call Stack (most recent call first):
D:/opencv-4.5.0/cmake/OpenCVModule.cmake:710 (ocv_target_include_modules)
D:/opencv_contrib/modules/xfeatures2d/CMakeLists.txt:17 (ocv_module_include_directories)
这是来自 "opencv_contrib\modules\sfm\CmakeLists.txt" 的代码片段,它导致了之前的输出:
if((gflags_FOUND OR GFLAGS_FOUND OR GFLAGS_INCLUDE_DIRS) AND (glog_FOUND OR GLOG_FOUND OR GLOG_INCLUDE_DIRS))
set(_fname "${CMAKE_CURRENT_BINARY_DIR}/test_sfm_deps.cpp")
file(WRITE "${_fname}" "#include <glog/logging.h>\n#include <gflags/gflags.h>\n int main() { (void)(0); return 0; }\n")
// This is reason of the fail
try_compile(SFM_DEPS_OK "${CMAKE_BINARY_DIR}" "${_fname}"
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${GLOG_INCLUDE_DIRS};${GFLAGS_INCLUDE_DIRS}"
LINK_LIBRARIES ${GLOG_LIBRARIES} ${GFLAGS_LIBRARIES}
OUTPUT_VARIABLE OUTPUT
)
file(REMOVE "${_fname}")
message(STATUS "Checking SFM deps... ${SFM_DEPS_OK}")
else()
set(SFM_DEPS_OK FALSE)
endif()
if(NOT HAVE_EIGEN OR NOT SFM_DEPS_OK)
set(DISABLE_MSG "Module opencv_sfm disabled because the following dependencies are not found:")
if(NOT HAVE_EIGEN)
set(DISABLE_MSG "${DISABLE_MSG} Eigen")
endif()
if(NOT SFM_DEPS_OK)
set(DISABLE_MSG "${DISABLE_MSG} Glog/Gflags")
endif()
message(STATUS ${DISABLE_MSG})
ocv_module_disable(sfm)
endif()
我认为cmake 中的gflags 和glog 路径有问题。我尝试了更多变体。 Here is the current settings Most of them are set based on Ceres Solver documentation.
配置:
- OpenCV 4.5.0
- OpenCV-contrib 4.5.0
- glog 0.4.0
- gflags 2.2.2
- Ceres 求解器 2.0.0
- 本征 3.3.9
- CMake 3.9.12
- Windows 10
类似问题:
- Module opencv_sfm disabled because the following dependencies are not found: Glog/Gflags #8536 - 仅针对 Ubuntu 解决。
- How can I only install some modules from opencv after make install? - 删除构建文件夹没有帮助。
- building opencv with sfm module issues - 在这里他建议下载所有部分的旧版本。
我在 cmake 中的 glog 参数设置不正确。
正确的设置如下:
- glog_DIR: 构建在哪里。应该有glog-config.cmake。路径:glog/out/build/x64-Debug
- GLOG_LIBRARIES:安装位置。 glogd.lib 的路径。路径:glog/out/install/x64-Debug/lib/glogd.lib
- GLOG_INCLUDE_DIR:安装位置。应该有名为 glog 的文件夹。路径:glog/out/install/x64-Debug/include
我无法使用 cmake 为 opencv 编译 sfm 模块。
如下日志显示cmake同时找到了glog和gflags,但是编译失败
Glog: YES
freetype2: NO
harfbuzz: NO
Julia not found. Not compiling Julia Bindings.
Module opencv_ovis disabled because OGRE3D was not found
No preference for use of exported gflags CMake configuration set, and no hints for include/library directories provided. Defaulting to preferring an installed/exported gflags CMake configuration if available.
Found installed version of gflags: D:/ceres/gflags/out/build/x64-Debug
Detected gflags version: 2.2.2
WARNING: Target "cmTC_9b54b" requests linking to directory "D:/ceres/glog/out/build/x64-Debug". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "cmTC_9b54b" requests linking to directory "D:/ceres/glog/out/build/x64-Debug". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "cmTC_9b54b" requests linking to directory "D:/ceres/glog/out/build/x64-Debug". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "cmTC_9b54b" requests linking to directory "D:/ceres/glog/out/build/x64-Debug". Targets may link only to libraries. CMake is dropping the item.
Checking SFM deps... FALSE
Module opencv_sfm disabled because the following dependencies are not found: Glog/Gflags
Tesseract: NO
Allocator metrics storage type: 'long long'
Registering hook 'INIT_MODULE_SOURCES_opencv_dnn': D:/opencv-4.5.0/modules/dnn/cmake/hooks/INIT_MODULE_SOURCES_opencv_dnn.cmake
opencv_dnn: filter out cuda4dnn source code
CMake Warning at D:/opencv-4.5.0/cmake/OpenCVModule.cmake:679 (message):
Unexpected include: D:/opencv-4.5.0/build/downloads/xfeatures2d
(module=opencv_xfeatures2d)
Call Stack (most recent call first):
D:/opencv-4.5.0/cmake/OpenCVModule.cmake:710 (ocv_target_include_modules)
D:/opencv_contrib/modules/xfeatures2d/CMakeLists.txt:17 (ocv_module_include_directories)
这是来自 "opencv_contrib\modules\sfm\CmakeLists.txt" 的代码片段,它导致了之前的输出:
if((gflags_FOUND OR GFLAGS_FOUND OR GFLAGS_INCLUDE_DIRS) AND (glog_FOUND OR GLOG_FOUND OR GLOG_INCLUDE_DIRS))
set(_fname "${CMAKE_CURRENT_BINARY_DIR}/test_sfm_deps.cpp")
file(WRITE "${_fname}" "#include <glog/logging.h>\n#include <gflags/gflags.h>\n int main() { (void)(0); return 0; }\n")
// This is reason of the fail
try_compile(SFM_DEPS_OK "${CMAKE_BINARY_DIR}" "${_fname}"
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${GLOG_INCLUDE_DIRS};${GFLAGS_INCLUDE_DIRS}"
LINK_LIBRARIES ${GLOG_LIBRARIES} ${GFLAGS_LIBRARIES}
OUTPUT_VARIABLE OUTPUT
)
file(REMOVE "${_fname}")
message(STATUS "Checking SFM deps... ${SFM_DEPS_OK}")
else()
set(SFM_DEPS_OK FALSE)
endif()
if(NOT HAVE_EIGEN OR NOT SFM_DEPS_OK)
set(DISABLE_MSG "Module opencv_sfm disabled because the following dependencies are not found:")
if(NOT HAVE_EIGEN)
set(DISABLE_MSG "${DISABLE_MSG} Eigen")
endif()
if(NOT SFM_DEPS_OK)
set(DISABLE_MSG "${DISABLE_MSG} Glog/Gflags")
endif()
message(STATUS ${DISABLE_MSG})
ocv_module_disable(sfm)
endif()
我认为cmake 中的gflags 和glog 路径有问题。我尝试了更多变体。 Here is the current settings Most of them are set based on Ceres Solver documentation.
配置:
- OpenCV 4.5.0
- OpenCV-contrib 4.5.0
- glog 0.4.0
- gflags 2.2.2
- Ceres 求解器 2.0.0
- 本征 3.3.9
- CMake 3.9.12
- Windows 10
类似问题:
- Module opencv_sfm disabled because the following dependencies are not found: Glog/Gflags #8536 - 仅针对 Ubuntu 解决。
- How can I only install some modules from opencv after make install? - 删除构建文件夹没有帮助。
- building opencv with sfm module issues - 在这里他建议下载所有部分的旧版本。
我在 cmake 中的 glog 参数设置不正确。
正确的设置如下:
- glog_DIR: 构建在哪里。应该有glog-config.cmake。路径:glog/out/build/x64-Debug
- GLOG_LIBRARIES:安装位置。 glogd.lib 的路径。路径:glog/out/install/x64-Debug/lib/glogd.lib
- GLOG_INCLUDE_DIR:安装位置。应该有名为 glog 的文件夹。路径:glog/out/install/x64-Debug/include