johanmaack
johanmaack

Reputation: 301

g++ programs for windows 98

I am trying to make programs for an old computer running Windows 98 second edition, but they won't run.

The programs are written in c++, and they are compiled with MinGW (g++ version 4.8.1) installed on a Windows Vista computer. For testing I tried this simple Hello World program:

#include <iostream>

using namespace std;

int main(){
    cout <<"hello world";
    return 0;
}

For compiling I used this command:

g++ hello.cpp -o hello.exe

When trying to run this program on the Windows 98 computer I get the following message:

A required .DLL file, LIBGCC_S_DW2-1.DLL, was not found.

So to make the executable as independent of dll-files as possible, I tried compiling the program with the command:

g++ hello.cpp -static -o hello.exe

But on trying the program on the Windows 98 computer, I now get the message:

The hello.exe file is linked to missing export MSVCRT.DLL:_fstat64

To analyze the problem, I tried a few things. And I noticed that compiling the same code with the same command using g++ version 2.95.2 instead, the program was able to run on the Windows 98 machine. However, I would prefer not to use this old version of g++ as it contains a few problematic bugs.

I also noticed that a similar program made in regular c (compiled with gcc version 4.8.1) also worked fine on the old computer, but I would prefer not to use regular c as this would require rewriting a lot of c++ code.

So the question is: how can I make c++ programs compiled with g++ 4.8.1 (or later) run on a Windows 98 machine?

Upvotes: 6

Views: 4327

Answers (2)

user6215161
user6215161

Reputation:

Late but better than never

found out later versions of MinGW doesn't run on windows 98 giving the error "A required .DLL file, LIBGCC_S_DW2-1.DLL, was not found."

the version of MinGW i tried and gave the error was this one (6.3.0-1) new version of MinGW

(i think you are referring to the dev version there, probably the bin version you had was more modern)

oddly, i recalled that time ago i compilled a build using Code::Blocks using MinGW that ran in windows 98, so i downloaded Code::Blocks version 17.12, and compilled the very same exe using the MinGW provided there directly, and worked just fine

and noticed it was a fairly older version ((tdm-1) 5.1.0) older version of MinGW

idk which was the latest version MinGW compilations worked on windows 98, i'll write a post about it in their forum soon

for the record, i'll show the pics of the test i did

on MinGW 6.3.0-1:

oh no!

on MinGW (tdm-1) 5.1.0:

woo!

so, to answer the question; yes, you can make programs for windows 98 using MinGW's g++ greater than version 4.8.1 (up to a certain version, i'll ask in the forum for more information)

EDIT: no need to, found this:

"The default mode is C++98 for GCC versions prior to 6.1, and C++14 for GCC 6.1 and above. You can use command-line flag -std to explicitly specify the C++ standard. For example,

-std=c++98, or -std=gnu++98 (C++98 with GNU extensions)
-std=c++11, or -std=gnu++11 (C++11 with GNU extensions)
-std=c++14, or -std=gnu++14 (C++14 with GNU extensions), default mode for GCC 6.1 and above.
-std=c++17, or -std=gnu++17 (C++17 with GNU extensions), experimental.
-std=c++2a, or -std=gnu++2a (C++2a with GNU extensions), experimental."

i added the -std=c++98 -std=gnu++98 flags to the 6.3.0-1 compiler and it worked fine on Windows 98 SE

Upvotes: 2

mirh
mirh

Reputation: 650

You can usually find msvcrt.dll by installing IE4
http://gnuwin32.sourceforge.net/packages/gcc.htm

Upvotes: 2

Related Questions