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

error in 2nd example #12

Open leslysandra opened 7 years ago

leslysandra commented 7 years ago

Hi! When I try to run basic.pp I get Segmentation fault (core dumped)

I will glad to receive any help.

DrRamm commented 7 years ago

I faced with same error(

[dr@ramm matplotlib-cpp]$ make cd examples && g++ minimal.cpp -lpython2.7 -o minimal -std=c++11 cd examples && g++ basic.cpp -lpython2.7 -o basic cd examples && g++ modern.cpp -lpython2.7 -o modern -std=c++11 [dr@ramm matplotlib-cpp]$ ls examples basic basic.cpp basic.png minimal minimal.cpp minimal.png modern modern.cpp modern.png [dr@ramm matplotlib-cpp]$ examples/basic Segmentation fault (core dumped)

lava commented 7 years ago

Maybe you could run it in gdb and post a backtrace of the place where the segmentation fault occurs?

DrRamm commented 7 years ago

[dr@ramm matplotlib-cpp]$ ls examples img img.cpp LICENSE LICENSE.matplotlib Makefile matplotlibcpp.h README.md [dr@ramm matplotlib-cpp]$ cd examples [dr@ramm examples]$ ls basic basic.cpp basic.png minimal minimal.cpp minimal.png modern modern.cpp modern.png [dr@ramm examples]$ ./minimal Ошибка сегментирования (стек памяти сброшен на диск) [dr@ramm examples]$ gdb ./minimal GNU gdb (GDB) 7.12 Copyright (C) 2016 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-pc-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: http://www.gnu.org/software/gdb/bugs/. Find the GDB manual and other documentation resources online at: http://www.gnu.org/software/gdb/documentation/. For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from ./minimal...(no debugging symbols found)...done. (gdb) run Starting program: /home/dr/Documents/tgbot/matplotlib-cpp/examples/minimal [Thread debugging using libthread_db enabled] Using host libthread_db library "/usr/lib/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault. 0x0000000000002230 in ?? () (gdb)

upd Seems like i found error (gdb) list 1 /build/gcc/src/gcc/libquadmath/math/x2y2m1q.c: Not such file or folder

lava commented 7 years ago

Well, you're almost there :) Just

1) Make sure you have checked out the latest commit without modifications 2) Add -g3 to your compiler flags when compiling minimal.cpp 3) Where you used the list command in gdb, use backtrace instead

DrRamm commented 7 years ago

thanks a lot, smthng weird with env on my OS, solved

carlosal1015 commented 2 years ago

With this example, is showed the Segmentation fault

#include <matplotlib-cpp/matplotlibcpp.h>

namespace plt = matplotlibcpp;

int main()
{
  std::vector<double> x = {1.5, 2.5, 3.5, 4.5},
                      y = {1, 3, 2, 4};

  plt::figure();
  plt::plot(x, y, "bo-");
  plt::xlabel("time [s]");
  plt::ylabel("observations [m]");
  plt::title("Matplotlib minimal example");
  plt::legend();
  plt::show();
  // plt::save("plot.png");

  return 0;
}

image