[error]No such file or directory (header file)

Error Detail

When I compile c++ file using g++ command as below, the fatal error: numpy/arrayobject.h: No such file or directory occurred.

>g++ filename.cpp -std=c++11 -IC:\Python27\include -lpython2.7
In file included from filename.cpp:1:
../libs/matplotlibcpp.h:17:12: fatal error: numpy/arrayobject.h: No such file or directory
   17 | #  include <numpy/arrayobject.h>

matplotlibcpp.h in the source code is c++ header file to plot a graph.

numpy/arrayobject.h is in the directory C:\Python27\Lib\site-packages\numpy\core\include\numpy.

Cause

The compiler could not find arrayobject.h because that file is not included in the include search path.

Solution

Add the path to arrayobject.h using -I command line option as follows.

>g++ filename.cpp -std=c++11 -IC:\Python27\include -lpython2.7 -IC:\Python27\Lib\site-packages\numpy\core\include