I have integrated Matplotlibcpp in my C++ project from :
https://github.com/lava/matplotlib-cpp
I am using Clion to build by project and here's how I did the linkage:
cmake_minimum_required(VERSION 3.13)
project(beep)
set(CMAKE_CXX_STANDARD 14)
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -g -ftest-coverage -fprofile-arcs" )
link_directories(C:/MinGW/lib)
find_package (Python3 COMPONENTS Interpreter NumPy)
include_directories(C:/Python37/include/)
link_libraries(C:/Python37/libs/libpython37.a Python3::NumPy)
include_directories( kissfft kissfft/tools matplotlib-cpp )
add_executable(beep kissfft matplotlib-cpp kissfft/tools/kiss_fftr.c kissfft/_kiss_fft_guts.h Beep_Generator.cpp plottingVector.h)
Here's my code:
#include "matplotlibcpp.h"
namespace plt = matplotlibcpp;
void plotting() {
try {
plt::plot( {1, 2, 3, 4, 5, 6},{0,1,2,3,4,5},"test");
plt::show();
}
catch (std::exception &e) {
cout << e.what() << endl;
}
When I run this code, I get this error of :
Call to show() failed.
When I debugged the code, I saw the problem here :
matplotlibcpp.h(Line # 1835): res = PyObject_CallObject(detail::_interpreter::get().s_python_function_show,detail::_interpreter::get().s_python_empty_tuple);
res becomes NULL.
What's the issue here? How can I solve it?
Regards, Khubaib