Cannot find 'gflags/gflags.h' while building library OSX
Asked Answered
S

1

6

I'm trying to build the library which included 'gflags/gflags.h' and am having trouble getting it to find.

I installed gflags and glog with homebrew.

CMake output says:

-- Found installed version of gflags: /usr/local/lib/cmake/gflags
-- Detected gflags version: 2.2.2
-- Found Gflags: /usr/local/include
-- Found Glog: /usr/local/include

While running "cmake" everything is okay there is no error. But when I run "make install" it cannot build and it says "fatal error: 'gflags/gflags.h' file not found"

How can I build the library which requires gflags in OsX?

Sandie answered 22/4, 2020 at 23:54 Comment(5)
try to see inside of Cmake file if Gflags path is set manually?Amygdalin
In Cmake file there is only find_package(Gflags REQUIRED) find_package(Glog REQUIRED)Sandie
Could you provide the CmakeList somehow? My guess is that you are not linking the gflags directory for your executable.Armelda
Please provide your CMake code, including the code showing how you use the Gflags variables after the calls to find_package(). Without seeing the code you are using, we can only guess what the problem might be...Saucier
@ThomasCaissard @squareskittles Thank you guys It was problem in include_directoriesSandie
S
5

First, find your package

find_package(Gflags REQUIRED)
find_package(Glog REQUIRED)

And then assign these library's header files to your executable include path

include_directories(${GLOG_INCLUDE_DIRS} ${GFLAGS_INCLUDE_DIRS})

Make sure that these variables are set properly

message(STATUS "GFLAGS include path: ${GFLAGS_INCLUDE_DIRS}")
Saucier answered 23/4, 2020 at 3:58 Comment(1)
gflag and glog provide Modern CMake Targets gflags::gflags et glog::glog -> stop using deprecated *_INCLUDE_DIRS. ThxJohen

© 2022 - 2024 — McMap. All rights reserved.