【发布时间】: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++