0

I'm trying to use spdlog as a logging library, but I do not want to use my package manager (apt) to install it. I have copied the spdlog directory under include to the root of my project directory, but when I try to compile I get include errors because the #include directives in the spdlog headers are all absolute (relative to the project root), instead of relative, gcc cannot find the files.

0:10: fatal error: spdlog/common.h: No such file or directory
 #include "spdlog/common.h"

Short of changing all the includes in the spdlog library to relative, how can I use spdlog in my project? I'm also using CMake to compile my project; I have a build directory in my project root and from within it I call cmake .. and then make to compile; is there something I need to add to my CMakeLists.txt file to include spdlog?

Nick Silvestri
  • 191
  • 1
  • 15
  • Possible duplicate of [CMake can not find include files](https://stackoverflow.com/questions/15449949/cmake-can-not-find-include-files) – Tsyvarev Oct 11 '18 at 07:40

1 Answers1

1

You need to add the project root directory into the cmake include_directories, like this:

include_directories(
    /absolute/path/
)

Or in the project root directory, edit CMakeLists.txt and add this:

include_directories(
    .
)
Wei Guo
  • 544
  • 3
  • 15
  • It was a matter of including the current directory in the search path. It seems obvious because the current directory is the one that contains `spdlog/` so then obviously the `spdlog/.h` can be resolved. Thanks. – Nick Silvestri Oct 11 '18 at 18:39