Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find 'gflags/gflags.h' while building library OSX

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?

like image 236
xfarxod Avatar asked Apr 22 '20 23:04

xfarxod


People also ask

How do I download and install the gflags library?

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.

How do I link against a specific gflags library in Linux?

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.

What are the default build settings for gflags?

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:

How do I choose a multi-threaded gflags library?

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).


1 Answers

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}")
like image 155
Kevin Avatar answered Oct 08 '22 14:10

Kevin