小编joh*_*ack的帖子

Windows 98 的 g++ 程序

我正在尝试为运行 Windows 98 第二版的旧计算机编写程序,但它们无法运行。

这些程序是用 c++ 编写的,并使用安装在 Windows Vista 计算机上的 MinGW(g++ 版本 4.8.1)进行编译。为了进行测试,我尝试了这个简单的 Hello World 程序:

#include <iostream>

using namespace std;

int main(){
    cout <<"hello world";
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

为了编译我使用了这个命令:

g++ hello.cpp -o hello.exe
Run Code Online (Sandbox Code Playgroud)

当尝试在 Windows 98 计算机上运行此程序时,我收到以下消息:

A required .DLL file, LIBGCC_S_DW2-1.DLL, was not found.
Run Code Online (Sandbox Code Playgroud)

因此,为了使可执行文件尽可能独立于 dll 文件,我尝试使用以下命令编译程序:

g++ hello.cpp -static -o hello.exe
Run Code Online (Sandbox Code Playgroud)

但在 Windows 98 计算机上尝试该程序时,我现在收到以下消息:

The hello.exe file is linked to missing export MSVCRT.DLL:_fstat64
Run Code Online (Sandbox Code Playgroud)

为了分析这个问题,我尝试了一些事情。我注意到,使用 g++ 版本 2.95.2 使用相同的命令编译相同的代码,该程序能够在 Windows 98 计算机上运行。但是,我不想使用这个旧版本的 g++,因为它包含一些有问题的错误。

我还注意到,用常规 c 编写的类似程序(用 gcc …

mingw g++ windows-98

6
推荐指数
1
解决办法
3772
查看次数

标签 统计

g++ ×1

mingw ×1

windows-98 ×1