首页 > 解决方案 > 安装 matplotlib-cpp 时遇到问题

问题描述

您好我正在尝试在 Arch 系统上安装库 matplotlib-cpp。这就是我得到的:

[luca@luca-mb matplotlib-cpp-master]$ make      
mkdir -p examples/build
g++ -o examples/build/lines3d examples/lines3d.cpp -I/usr/include/python3.9 -I/usr/include/python3.9 -I/home/luca/.local/lib/python3.9/site-packages/numpy/core/include -std=c++11 -Wno-conversion  -L/usr/lib -lpython3.9 -lcrypt -lpthread -ldl  -lutil -lm -lm 
examples/lines3d.cpp: In function ‘int main()’:
examples/lines3d.cpp:24:33: error: no matching function for call to ‘plot3(std::vector<double>&, std::vector<double>&, std::vector<double>&, std::map<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> >&)’
   24 |     plt::plot3(x, y, z, keywords);
      |                                 ^
In file included from examples/lines3d.cpp:1:
examples/../matplotlibcpp.h:586:6: note: candidate: ‘template<class Numeric> void matplotlibcpp::plot3(const std::vector<Numeric>&, const std::vector<Numeric>&, const std::vector<Numeric>&, long int, const std::map<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> >&)’
  586 | void plot3(const std::vector<Numeric> &x,
      |      ^~~~~
examples/../matplotlibcpp.h:586:6: note:   template argument deduction/substitution failed:
examples/lines3d.cpp:24:25: note:   cannot convert ‘keywords’ (type ‘std::map<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> >’) to type ‘long int’
   24 |     plt::plot3(x, y, z, keywords);
      |                         ^~~~~~~~
make: *** [Makefile:38: examples/build/lines3d] Error 1

我已经尝试为此安装和所有必要的 python 库,但到目前为止还没有锁定。任何人都可以看到问题出在哪里?

谢谢。

标签: c++matplotlibinstallationcmake

解决方案


您不必构建任何东西来安装 matplotlib-cpp

库的 C++ 部分由matplotlibcpp.h可以放在任何地方的单个头文件组成。

既然你在 Arch,我会使用matplotlib-cpp-git AUR 包。它只是将单个头文件安装到/usr/include/matplotlib-cpp/matplotlibcpp.h,但走 AUR 路线意味着该文件将被pacman.


推荐阅读