matplotlib-cpp icon indicating copy to clipboard operation
matplotlib-cpp copied to clipboard

error in 2nd example

Open leslysandra opened this issue 9 years ago • 6 comments

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

I will glad to receive any help.

leslysandra avatar Oct 11 '16 09:10 leslysandra

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)

DrRamm avatar Feb 17 '17 12:02 DrRamm

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

lava avatar Feb 18 '17 11:02 lava

[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

DrRamm avatar Feb 19 '17 15:02 DrRamm

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

lava avatar Feb 20 '17 12:02 lava

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

DrRamm avatar Feb 25 '17 15:02 DrRamm

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

carlosal1015 avatar May 17 '22 04:05 carlosal1015