c++ - cygwin_exception::open_stackdumpfile:将堆栈跟踪转储到 *.exe.stackdump

标签 c++ eclipse stack-trace eigen

我收到“cygwin_exception::open_stackdumpfile:将堆栈跟踪转储到 TestProject.exe.stackdump”错误。我的项目只不过是一个 C++ HalloWorld 项目,它包含一个附加类,我在其中设置和获取一个变量。我在尝试设置 Eigen 类型的矩阵变量的那一行遇到了这个错误。这是我的代码:

测试项目.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;
}

测试类.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_ */

最后是 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;
}

我在控制台中得到的输出是:

!!!Hello World!!!
      0 [main] TestProject 8416 cygwin_exception::open_stackdumpfile: Dumping stack trace to TestProject.exe.stackdump

值得一提的是,当我将类变量 X 的类型(以及方法和头文件中的所有相关类型)更改为整数时,我没有收到此错误并且代码编译并运行。

我将不胜感激,因为我没有在网上找到有用的信息。

谢谢

最佳答案

您正在使用一个动态大小的 Matrix X,并且您尝试在不先设置其大小的情况下对其进行逗号初始化。这将引发异常:

如解释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.

here :

The coefficients must be provided in a row major order and exactly match the size of the matrix. Otherwise an assertion is raised.

所以首先调整矩阵的大小:

TestClass::TestClass() {
    X.resize (1,3); 
    X << 0, 1, 2;
}

关于c++ - cygwin_exception::open_stackdumpfile:将堆栈跟踪转储到 *.exe.stackdump,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31676122/

相关文章:

Java printf 语句给出错误

java - Java 中的断言不安全吗?

javascript - 如何默认隐藏 Node.js 中的内部堆栈跟踪错误?

c++ - 在 Vector C++ 中查找最后定义的元素

java - 在eclipse中编译spark项目时出现问题

javascript - 从插件调用代码时出现问题 : "org.eclipse.core.resources" when using eclipse

python - 如何从 Python 中的异常对象获取堆栈跟踪?

c++ - 在 Windows 服务器上使用卡萨布兰卡

c++ - 针对非类型参数特定值的模板代码优化。

c++ - 将接口(interface)包装在库中的类周围