【问题标题】:devc++ compilation errors for 1st time user第一次用户的 dev c++ 编译错误
【发布时间】:2014-04-12 20:49:19
【问题描述】:

我有这个代码

#include <iostream>
#include <cmath>
using namespace std;

int main()
{
    double a,b,c;
    double x,x2;
    cout<<"Give a: ";
    cin>>a;
    cout<<"Give b: ";
    cin>>b;
    cout <<"Give c: ";
    cin>>c;
    if (a==0)
    {
        if (b==0)
        {
            if (c==0)
            {
            cout<<"Solution indeterminable";
            return 0;
            }
            else 
            {
            cout<<"No solution";
            return 0;
            }   
        }
        else
        {
        x=-c/b;
        cout<<"The only root is x: "<<x;
        return 0;
        }

    }
    else
    {
    double b_sqr=b*b;
    if (b_sqr>4*b*c)
        {
        cout<<"Complex roots: ";
        return 0;
        }
    else if (b_sqr==4*b*c)
        {
        x=-b/(2*a);
        cout<<"The only solution is x: "<<x;
        return 0;
        }
    else
        {
            x=-b+(sqrt((b*b)-(4*a*c)))/(2*2);
            x2=-b-(sqrt((b*b)-(4*a*c)))/(2*2);
            cout<<"The first root is x1: "<<x;
            cout<<"The first root is x2: "<<x2;
            return 0;
        }
    }
}

当我尝试使用 devc++ 进行编译时,出现以下错误:

found dwarf version '4', this reader only handles version 2 information. 
  [Linker error] undefined reference to `__dyn_tls_init_callback' 
  [Linker error] undefined reference to `__cpu_features_init' 
  [Linker error] undefined reference to `__chkstk_ms' 
  [Linker error] undefined reference to `__mingw_glob' 
  [Linker error] undefined reference to `__mingw_glob' 
  ld returned 1 exit status 

这是我第一次使用 devc++。代码似乎没问题。有任何想法吗? 我使用的平台是Windows 7 64位版本。

【问题讨论】:

  • 请不要使用 Dev-C++。它被认为是过时的。此外,它不是编译器——这个 IDE 的底层编译器似乎是 MinGW,相当于 GCC。
  • 如果您想使用 IDE 学习 C++,请使用 Visual Studio Express 桌面版。它是免费且易于设置的。如果您不介意深入研究命令行内容,请使用您喜欢的任何编辑器和 mingw。 (或者,更好的是,安装 Linux 或在 VM 中使用它。)

标签: c++ windows-7 compilation dev-c++


【解决方案1】:

我认为您收到此错误是因为您的编译器路径设置不正确。

这可能会对您有所帮助:

Tools > Compiler Options... 并添加编译器文件夹。

【讨论】:

    【解决方案2】:

    在许多错误和其他用户 More Axes 的推荐之后,我离开了 DevC++。

    我建议任何想要使用它的人都这样做并远离它,因为它已经过时了。

    如果你想使用 Windows 平台下的 IDE,你可以使用 Visual Studio,或者 Eclipse。

    如果您只想使用编译器,请使用 MinGW。 (然后不要忘记将二进制文件的位置添加到 PATH 环境变量中,以便从命令行运行)

    【讨论】:

      猜你喜欢
      • 2011-05-16
      • 1970-01-01
      • 2012-07-23
      • 1970-01-01
      • 2011-01-10
      • 2013-02-21
      • 2012-05-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多