0

I am trying to use spdlog library in an hello world.

#include "spdlog/spdlog.h"

int main()
{
    return 0;
}

Since it is "header only" library I just copied it to my project's root and expected everything to just work.

|+ hello.cpp                         
|+ spdlog |         
          |+ spdlog.h
          |+common.h
     .....     

but when I build gcc hello.cpp

I get:
spdlog/spdlog.h:10:10: fatal error: spdlog/common.h: No such file or directory #include "spdlog/common.h"
The problem is that everywhere in the spdlog library it reference files under the spdlog folder. In the example error above, the spdlog.h is including the common.h which is in the same folder. But it is included like this:
#include "spdlog/common.h" Why does the "spdlog" is prepended in all the includes to all the headers?
What should I do in order to use spdlog? edit its includes?

kroiz
  • 1,722
  • 1
  • 27
  • 43
  • 1
    Can you post your entire compilation line. If It is only GCC hello.cpp then you should add -I"PATH to spdlog folder" or -I. – PilouPili Oct 06 '18 at 13:07

1 Answers1

1

As your headers files path is spdlog/.h so you should provide path of your spdlog folder resides. like

gcc -c -I/<Path of spdlog parent folder> hello.cpp
Sanjeev
  • 348
  • 2
  • 9