ceres-solver / ceres-solver

A large scale non-linear optimization library

Home Page:http://ceres-solver.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

When I execute the cmake, it says add_library cannot create imported target "glog::glog" because another target with the same name already exists.

zyzn opened this issue · comments

commented

-- Found Glog
-- Includes : /usr/include
-- Libraries : /usr/lib/x86_64-linux-gnu/libglog.so
-- Found SQLite3: /usr/include (found version "3.31.1")
-- Found OpenGL: /usr/lib/x86_64-linux-gnu/libOpenGL.so
-- Found Git: /usr/bin/git (found version "2.25.1")
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Found required Ceres dependency: Eigen version 3.3.7 in /usr/lib/cmake/eigen3
CMake Error at /usr/local/lib/cmake/Ceres/FindGlog.cmake:349 (add_library):
add_library cannot create imported target "glog::glog" because another
target with the same name already exists.
Call Stack (most recent call first):
/usr/local/lib/cmake/Ceres/CeresConfig.cmake:247 (find_package)
cmake/FindDependencies.cmake:33 (find_package)
CMakeLists.txt:85 (include)

-- Found required Ceres dependency: glog
-- Found Ceres version: 2.2.0 installed in: /usr/local with components: [EigenSparse, SparseLinearAlgebraLibrary, SchurSpecializations]

Unfortunately, it is not possible to debug the issue with the information you have provided as previously noted in google/glog#4 (comment).

Could you provide more context? What project are you trying to configure here as this does not look like it is actually Ceres as it neither depends on SQLite3 nor OpenGL. Other than that, you could test the current development version of Ceres which does not rely on FindGlog.cmake anymore.

commented

Thanks for your reply. I solved it by using the method in https://blog.csdn.net/hhhyxnh/article/details/133833064?spm=1001.2014.3001.5502

I had the same issue trying to compile COLMAP. It appears that ceres load glog::glog as it was already loaded before by CMake. To fix this I edited /usr/local/lib/cmake/Ceres/FindGlog.cmake line 348 with:

# add glog::glog target
if(NOT TARGET glog::glog)
    add_library(glog::glog INTERFACE IMPORTED)
    target_include_directories(glog::glog INTERFACE ${GLOG_INCLUDE_DIRS})
    target_link_libraries(glog::glog INTERFACE ${GLOG_LIBRARY})
endif()

I hope this will help