Using GDB with Eigen C++ library

我的未来我决定 提交于 2019-11-29 12:36:33

问题


I am using the Eigen C++ library downloadable from http://eigen.tuxfamily.org/. This is a C++ library for easier handling of Matrices and Arrays. I use g++ compiler and gdb for debugging. However, I found that I am unable to print the content of a Matrix (provided by Eigen) while using gdb.


回答1:


You have to install a gdb extension that you can find in eigen/debug/gdb/.

The comment at the beginning of the file explains how to install it.




回答2:


One trick you can use is the .data() member, it gives you a pointer to the raw array that contains the data. With that you can print it in GDB like so:

print *X.data()@Length_X

where X is the eigen variable and Length_X is the product of its rows and columns.



来源:https://stackoverflow.com/questions/25085465/using-gdb-with-eigen-c-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!