2

In my project, in the "configure" phase my CMake seems to find glog, but in the building phase I receive the error message: cannot find -llibglog

It makes no difference if I use

sudo apt-get install libgoogle-glog-dev

or generate glog from source. Recently I had to ugrade to Ubuntu 16.04 from 14.04, and have series of problems, from source redefinition problems to building problems like this.

Edited: It is a complex project, with many subprojects and packages, so it would not fair to post so many files. And, it worked before upgrading.

The relevant parts:

(FindGlog.cmake)
find_package_handle_standard_args(Glog DEFAULT_MSG GLOG_INCLUDE_DIR GLOG_LIBRARY)

if(GLOG_FOUND)
  set(GLOG_INCLUDE_DIRS ${GLOG_INCLUDE_DIR})
  set(GLOG_LIBRARIES ${GLOG_LIBRARY})
  message(STATUS "Found glog    (include: ${GLOG_INCLUDE_DIR}, library: ${GLOG_LIBRARY})")
  mark_as_advanced(GLOG_ROOT_DIR GLOG_LIBRARY_RELEASE GLOG_LIBRARY_DEBUG
                                 GLOG_LIBRARY GLOG_INCLUDE_DIR)
endif()

and CMakeLists.txt

target_link_libraries( simtest libmain libglog ${Pthread} )

and the message /usr/bin/ls: cannot find --libglog

katang
  • 2,474
  • 5
  • 24
  • 48
  • 1
    You should use `${GLOG_LIBRARIES}` for link with glog. This is why `find_package(Glog)` is needed. – Tsyvarev Jun 02 '16 at 19:42
  • @Tsyvarev This really helped, thank you. I used ${Caffe_LINKER_LIBS}, which worked quite till this version change, and I guessed it makes what you suggested. Do you have any idea, what changed and why with this version change? – katang Jun 06 '16 at 16:23
  • Using library name with `target_link_libraries` implies that library file is located under directory which either is searched by the linked *by default*, or has been added previously by `link_directory` command. Variable `${GLOG_LIBRARIES}` contains **absolute path** to the library file, so it is found by the linked in any case. – Tsyvarev Jun 06 '16 at 17:19

0 Answers0