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?
The gflags library can be downloaded from GitHub . You can clone the project using the command: Build and installation instructions are provided in the INSTALL file. The installation of the gflags package includes configuration files for popular build systems such as pkg-config , CMake, and Bazel.
To request a particular imported gflags library target to link against, use the COMPONENTS option of the find_package command. For example, to force the use of the single-threaded static library, use the command Note that this will raise a fatal error when the installed gflags package does not contain the requested library.
The default build settings are the build of a single-threaded static library which does not require any installation of the gflags subproject products. Finally, add your executable build target which uses gflags to parse the command arguments with dependency on the imported gflags library target:
By default, the multi-threaded gflags library with shared linkage is chosen if available. When the source tree of the gflags project is included as subtree or submodule in the "gflags" directory of your project, replace the above find_package command by add_subdirectory (gflags).
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}")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With