1

I am trying to rewrite the pycaffe code using C++ Caffe API. However, I get stuck at the very beginning. None of the following

#include <caffe.hpp> 

#include <caffe/caffe.hpp> 

#include <home/username/caffe/caffe.hpp>

works because the path to the caffe is not known the way it is given by PYTHONPATH in the pycaffe code. How then do I add the caffe module in the C++ code?

cerebrou
  • 5,353
  • 15
  • 48
  • 80
  • You have to tell the compiler and linker where the header and library files are located. The common way to do it is with an option like `-I` (upper-case i) for header files. Like e.g. `g++ -I/location/of/caffe/headers ...` – Some programmer dude Sep 26 '17 at 11:38
  • 1
    That last one could work if you use the absolute path, e.g. `/home/username/caffe/`. – Maxim Egorushkin Sep 26 '17 at 11:39

2 Answers2

3

The path to directories with additional headers must be specified to the compiler. Often, using -I<include-path> command line switch, e.g. -I/home/username/caffe.

Your build system may offer a few different ways of adding additional include directories.

Maxim Egorushkin
  • 131,725
  • 17
  • 180
  • 271
0

The counterpart of the PYTHONPATH is CPLUS_INCLUDE_PATH, which can be used in the following way:

export CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:/home/username/caffe/include/

and then

#include "caffe/caffe.hpp"

There may be some other path headers missing, in such a case adding the paths to those headers to the CPLUS_INCLUDE_PATH will solve the issue.

cerebrou
  • 5,353
  • 15
  • 48
  • 80
  • see [this thread](https://stackoverflow.com/a/558819/1714410) for more information. – Shai Sep 26 '17 at 12:34