c++visual-studiovisual-studio-2017-build-tools

Unhandled exception at 0x00007FFE9ECECF19 in ...: Microsoft C++ exception: std::runtime_error at memory location 0x000000F632EFEC68


I have compiled Matplot++ 1.2.0 into a static lib file using the following commands:

1. git clone https://github.com/alandefreitas/matplotplusplus.git

2. cd matplotplusplus

3. mkdir build

4. cd build

5. cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_BUILD_TYPE=Debug ..

6. cmake --build . --config Debug

Then I created a Windows Console application project. Then I added the iclude path, lib path, and lib file-names from the project settings for both the debug and release settings separately.

Then I changed the code generation to ISO C++17.

Then I built the project with the following message:

#include <matplot\matplot.h>
#include <vector>

int main()
{
    try {
        using namespace matplot;

        // Generate some data to plot
        std::vector<double> x = linspace(0, 2 * pi, 100);
        std::vector<double> y = transform(x, [](double xi) { return sin(xi); });

        // Plot the data
        plot(x, y);

        // Display the plot with appropriate labels
        title("Sine Wave");
        xlabel("x");
        ylabel("sin(x)");

        // Save the plot to a file
        save("sine_wave.png");

        // Show the plot in a window
        show();
    }
    catch (const std::runtime_error& e) {
        std::cerr << "Runtime error: " << e.what() << std::endl;
    }

    return 0;
}
1>------ Rebuild All started: Project: MatplotPlusPlus__test, Configuration: Debug x64 ------
1>Source.cpp
1>   Creating library C:\git\MatPlotPlusPlus__test\x64\Debug\MatplotPlusPlus__test.lib and object C:\git\MatPlotPlusPlus__test\x64\Debug\MatplotPlusPlus__test.exp
1>MatplotPlusPlus__test.vcxproj -> C:\git\MatPlotPlusPlus__test\x64\Debug\MatplotPlusPlus__test.exe
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

However, when I execute the project, I get the following error without exception handling:

Unhandled exception at 0x00007FFE9ECECF19 in MatplotPlusPlus__test.exe: 
Microsoft C++ exception: std::runtime_error at memory location 0x000000F632EFEC68.

I get the followinh error with exception handling:

Runtime error: popen() failed!
Press any key to continue . . .

enter image description here

This error is pointing to the file C:\git\MatPlotPlusPlus__test\external_libs\Matplot++ 1.2.0\include\matplot\freestanding\plot.h.

What is causing this issue?


Solution

  • enter image description here

    Indeed, the Matplot++ calls GNUplot to render the graphics.

    So, I installed GNUPlot, and now my program is displaying the plot.

    enter image description here