c++ 可执行文件不能在 windows 7 中运行 - 64 位不兼容

标签 c++ windows-7 64-bit compatibility

我写了一个简单的 C++ 程序来计算二次方程。我在 ubuntu linux 上用 g++ 编译了它。

顺便说一下代码:

#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;
        }
    }
}

现在,当我尝试在我的 x64 Windows 7 上运行它时,这就是我得到的:

不支持的 16 位应用程序:

由于与 64 位版本的 windows 不兼容,程序或功能 equation.exe 无法启动或运行。请联系软件供应商询问是否有 64 位 Windows 兼容版本可用

好吧,我是作者,我编写了 simpe c++ 来对其进行编码。这个兼容性问题是怎么回事?

我如何设法在 Windows 7 x64 上运行它? 谢谢!

最佳答案

Windows 无法运行针对其他操作系统的可执行文件。您需要使用面向 Windows 的编译器重新编译。例如 mingw 可能是 Windows 使用最广泛的 GCC 端口。

关于c++ 可执行文件不能在 windows 7 中运行 - 64 位不兼容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23035472/

相关文章:

c++ - 如何决定何时实现 C++ 模板?

c++ - 什么是 std::promise?

c# - 在 Visual Studio 2010 中调试时出现 fatal error HRESULT=0x80131c08

c# - 为什么我不能通过 pinvoke 使 GetPrivateProfileString 工作?

javascript - Internet Explorer 11 不支持 javascript window.open() 函数的此类接口(interface)

java - Eclipse(Java/SWT 应用程序): Reconfigure to run as 64-bit

c++ - 在两个线程之间共享一个 int 时可能会出现什么问题?

c++ - RegQueryValueExW 只从注册表中取回一个值

c++ - GetForegroundWindow 从 Windows 7 上的服务

mysql - 如何在 Windows 7 中使用命令行执行大型 MySQL 数据插入脚本文件?