我想提出一个关于 MinGW 4.7.2 的问题我第一次遇到 libstdc++-6.dll 引起的致命问题,当时我在 OpenCV 中冒险。幸运的是,我在这里遇到了一种解决方法-> http://answers.opencv.org/question/3740/opencv-243-mingw-cannot-run-program/。它看起来很棒,有一段时间。
现在我正在尝试实现复数。我尝试以下代码
#include <iostream>
#include <complex.h>
using namespace std;
int main(int argc, char* argv[])
{
float _Complex d = 2.0f + 2.0f*I;
cout << "Testing Complex\t" << d;
return 0;
}
它应该运行,无论如何。链接时我没有遇到任何错误或警告。我在 Windows 中使用 CodeBlocks 作为我首选的 IDE。但是,再一次,我被困住了。这是 AppCrash 报告
Problem signature:
Problem Event Name: APPCRASH
Application Name: complex.exe
Application Version: 0.0.0.0
Application Timestamp: 515d61f7
Fault Module Name: libstdc++-6.dll
Fault Module Version: 0.0.0.0
Fault Module Timestamp: 4ed82a4d
Exception Code: c0000005
Exception Offset: 000462bc
OS Version: 6.1.7600.2.0.0.256.1
Locale ID: 1033
Additional Information 1: 0a9e
Additional Information 2: 0a9e372d3b4ad19135b953a78882e789
Additional Information 3: 0a9e
Additional Information 4: 0a9e372d3b4ad19135b953a78882e789
然而令人惊讶的是,如何在 C 中处理复数?提供完美运行的 C 代码!
#include <stdio.h> /* Standard Library of Input and Output */
#include <complex.h> /* Standart Library of Complex Numbers */
int main()
{
double complex z1 = 1.0 + 3.0 * I;
double complex z2 = 1.0 - 4.0 * I;
printf("Working with complex numbers:\n");
printf("Starting values: Z1 = %.2f + %.2fi\tZ2 = %.2f + %.2fi\n",creal(z1),cimag(z1),creal(z2),cimag(z2));
double complex sum = z1 + z2;
printf("The sum: Z1 + Z2 = %.2f %+.2fi\n", creal(sum), cimag(sum));
return 0;
}
如您所见,错误的 libstdc++-6.dll 再次发挥作用。这次任何人都可以建议我任何解决方法,希望不会降级到以前版本的 MinGW,因为那时我将不得不重建我所有的库。
任何帮助将不胜感激!