问题
I am getting "cygwin_exception::open_stackdumpfile: Dumping stack trace to TestProject.exe.stackdump" error. My project is nothing but a C++ HalloWorld project that contains an additional class in which I set and get a variable. I am getting this error at the line I try to set a matrix variable of type Eigen. Here is my code:
TestProject.cpp
#include <iostream>
#include "TestClass.hpp"
using namespace std;
int main() {
cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
TestClass testClass;
Eigen::MatrixXd XX = testClass.getVariable();
cout << "X = " << XX;
return 0;
}
TestClass.hpp:
#ifndef TESTCLASS_HPP_
#define TESTCLASS_HPP_
#include <Eigen/Core>
#include <Eigen/Eigenvalues>
#include <unsupported/Eigen/MatrixFunctions>
#include <Eigen/Geometry>
class TestClass {
private:
Eigen::MatrixXd X;
public:
TestClass();
void setVariable(Eigen::MatrixXd);
Eigen::MatrixXd getVariable();
virtual ~TestClass();
};
#endif /* TESTCLASS_HPP_ */
and finally the TestClass.cpp:
#include "TestClass.hpp"
using namespace std;
TestClass::TestClass() {
X << 0, 1, 2;
}
TestClass::~TestClass() {
// TODO Auto-generated destructor stub
}
void TestClass::setVariable(Eigen::MatrixXd x){
X = x;
}
/* namespace std */
Eigen::MatrixXd TestClass::getVariable(){
return X;
}
The output I get in the Console is:
!!!Hello World!!!
0 [main] TestProject 8416 cygwin_exception::open_stackdumpfile: Dumping stack trace to TestProject.exe.stackdump
It is worth mentioning that when I change the type of the class variable X (and all related types in the methods and the header file) into an integer I don't get this error and the code compiles and runs.
I would appreciate any help since I didn't find useful info online.
Thanks
回答1:
You are using a dynamic sized Matrix X, and you try to comma initialize it without setting its size first. This will raise an exception:
As explained here:
Eigen offers a comma initializer syntax which allows the user to easily set all the coefficients of a matrix, vector or array. Simply list the coefficients, starting at the top-left corner and moving from left to right and from the top to the bottom. The size of the object needs to be specified beforehand.
and here:
The coefficients must be provided in a row major order and exactly match the size of the matrix. Otherwise an assertion is raised.
So resize your matrix first:
TestClass::TestClass() {
X.resize (1,3);
X << 0, 1, 2;
}
来源:https://stackoverflow.com/questions/31676122/cygwin-exceptionopen-stackdumpfile-dumping-stack-trace-to-exe-stackdump