Eclipse GCC 5.0 Mac,出错:中止陷阱6

时间:2015-01-14 22:50:32

标签: c++ eclipse macos c++11 gcc

我正在尝试使用Mac上的GCC 5.0构建我在Eclipse中创建的项目。

我将项目的环境变量设置为: CPATH: $ {HOME} / GCC /包括

LIBRARY_PATH: $ {HOME | / GCC / lib中

路径: $ {HOME} / GCC /斌:  的/ usr / bin中:/ bin中:/ usr / sbin目录:/ sbin目录

我在标志中添加了-std = c ++ 11.

我添加了DYLD_LIBRARY_PATH: DYLD_LIBRARY_PATH: $ {ENV_VAR:HOME} / GCC / lib中

但是,当我构建项目时,我收到以下错误:

`Description    Resource    Path    Location    Type
make: *** [eulerclass.o] Abort trap: 6  Euler's Method          C/C++ Problem`

我的CPP文件如下:

#include <iomanip>
#include <iostream>

typedef double F(double,double);

/*
Approximates y(t) in y'(t)=f(t,y) with y(a)=y0 and
t=a..b and the step size h.
*/
void euler(F f, double y0, double a, double b, double h)
{
    double y = y0;
    for (double t = a; t < b; t += h)
    {
        std::cout << std::fixed << std::setprecision(3) << t << " " << y << "\n";
        y += h * f(t, y);
    }
    std::cout << "done\n";
}

// Example: Newton's cooling law
double newtonCoolingLaw(double, double t)
{
   return -0.07 * (t - 20);
}

int main()
{
    euler(newtonCoolingLaw, 100, 0, 100,  2);
    euler(newtonCoolingLaw, 100, 0, 100,  5);
    euler(newtonCoolingLaw, 100, 0, 100, 10);
}

为什么我收到此错误的任何想法?

注意:我能够使用终端命令clang++成功编译和运行可执行文件,所以我知道文件没问题。它必须是Eclipse的错误,但我不知道是什么。

提前致谢!

0 个答案:

没有答案
相关问题