jupyter-xeus / xeus-cling

Jupyter kernel for the C++ programming language
BSD 3-Clause "New" or "Revised" License
3.01k stars 294 forks source link

add_include_path for numpy include headers isn't detected #505

Open kfirufk opened 7 months ago

kfirufk commented 7 months ago

Hi, I'm trying to get matplotlib-cpp to work, there is wonderful example at https://github.com/jupyter-xeus/xeus-cling/issues/255 for that, but unfortunately it does not work in my case.

I'm on Gentoo Linux with python 3.11.6

i created the following code snippet in the notebook:

#pragma cling add_include_path("/usr/include/python3.11")
#pragma cling add_include_path("/usr/lib/python3.11/site-packages/numpy/core/include")

#include "matplotlibcpp.h"
#include <vector>
#include <cmath>

namespace plt = matplotlibcpp;

    std::vector<double> t(1000);
    std::vector<double> x(t.size());

    for(size_t i = 0; i < t.size(); i++) {
        t[i] = i / 100.0;
        x[i] = sin(2.0 * M_PI * 1.0 * t[i]);
    }

    plt::xkcd();
    plt::plot(t, x);
    plt::title("AN ORDINARY SIN WAVE");
    plt::show();

and I get:

In file included from input_line_19:1:
/usr/local/include/matplotlibcpp.h:20:12: fatal error: 'numpy/arrayobject.h' file not found
#  include <numpy/arrayobject.h>
           ^~~~~~~~~~~~~~~~~~~~~

Interpreter Error: 

I know that the add_include_path functionality works cause before i included /usr/include/python3.11 i would get error about missing Python.h. directory /usr/lib/python3.11/site-packages/numpy/core/include includes numpy/arrayobject.h, so what am I missing?