lava / matplotlib-cpp

Extremely simple yet powerful header-only C++ plotting library built on the popular matplotlib
MIT License
4.37k stars 1.13k forks source link

Cannot compile with Python3.6 using simple example #89

Open timduly4 opened 5 years ago

timduly4 commented 5 years ago

I am trying to compile the simple modern.cpp example listed on the front page, but receive the following error:

$ g++ modern.cpp -I/usr/include/python3.6 -lpython3.6 --std=c++11

In file included from modern.cpp:2:0:
matplotlibcpp.h: In function 'void matplotlibcpp::plot_surface(const std::vector<std::vector<Numeric> >&, const std::vector<std::vector<Numeric> >&, const std::vector<std::vector<Numeric> >&, const std::map<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> >&)':
matplotlibcpp.h:445:43: error: there are no arguments to 'PyInt_FromLong' that depend on a template parameter, so a declaration of 'PyInt_FromLong' must be available [-fpermissive]
   PyDict_SetItemString(kwargs, "rstride", PyInt_FromLong(1));
                                           ^~~~~~~~~~~~~~
matplotlibcpp.h:445:43: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
matplotlibcpp.h:446:43: error: there are no arguments to 'PyInt_FromLong' that depend on a template parameter, so a declaration of 'PyInt_FromLong' must be available [-fpermissive]
   PyDict_SetItemString(kwargs, "cstride", PyInt_FromLong(1));
timduly4 commented 5 years ago

I resolved this issue by changing PyInt_FromLong to PyLong_FromLong in the matplotlibcpp.h file.