【问题标题】:cygwin_exception::open_stackdumpfile: Dumping stack trace to *.exe.stackdumpcygwin_exception::open_stackdumpfile:将堆栈跟踪转储到 *.exe.stackdump
【发布时间】:2015-07-28 20:37:23
【问题描述】:

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

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_ */

最后是 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 的类型(以及方法和头文件中的所有相关类型)更改为整数时,我没有收到此错误并且代码编译并运行。

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

谢谢

【问题讨论】:

    标签: c++ eclipse stack-trace eigen


    【解决方案1】:

    您正在使用动态大小的 Matrix X,并且您尝试用逗号初始化它而不先设置它的大小。这将引发异常:

    正如here解释的那样:

    Eigen 提供了一个逗号初始化语法,允许用户 轻松设置矩阵、向量或数组的所有系数。简单地 列出系数,从左上角开始,从 从左到右,从上到下。 对象的大小 需要事先指定

    here:

    系数必须以行的主要顺序提供,并且准确无误 匹配矩阵的大小。否则会引发断言。

    所以先调整矩阵的大小:

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

    【讨论】:

      猜你喜欢
      • 2015-04-25
      • 1970-01-01
      • 1970-01-01
      • 2021-07-02
      • 1970-01-01
      • 2020-12-04
      • 2019-08-06
      • 2013-10-06
      • 2017-12-31
      相关资源
      最近更新 更多