C++ program compatible with Windows 95
Asked Answered
H

3

7

I made the mistake of thinking that the C++ program that I coded with VS 2012 would work on a computer running windows 95.

Now I know why it doesn't work. So I took a look at other free compilers such as Dev-C++ 5 but after going through the forum of the Dev-C++ web site, it seems that it also can't be used make Windows 95 compatible applications.

So my question is, what should I use to compile my C++ application in order for it to work on Windows 95 and all the other versions of windows from 95 to 8?

Edit : After no suitable answer.

I don't mind having to build a different .exe for different Windows versions.

Edit : Problem solved!

Thanks to everyone who help in this discussion.

Using MingW and code blocks it took me only 20 minutes to adapt the code to Win 95 friendly libraries... and a full day to install Win 95 in a VM lol.

Haematopoiesis answered 9/4, 2013 at 19:37 Comment(16)
Visual Studio 6.0 or an older version of Cygwin are probably going to be your best bets. You may however need to upgrade or install a newer version of the windows SDK than the one that comes with the toolchain.Cortes
VS 2012 should work, you just have to specify the correct runtime library version …Glottochronology
Define "doesn't work"Hellenic
@Konrad Rudolph : I only have the choice between Multi-threaded(/MT) or multi-Thread dll(/MD). Which one do I need? My project was currently in /MTHaematopoiesis
@SimonCorcos That isn’t the right switch.Glottochronology
@Hellenic : Pop up window with "xxxxx.exe is not a valid win32 application" when I try to launch the app.Haematopoiesis
@Konrad Rudolph : Thanks for the quick answer but I just went through all my project settings without finding what you're talking about. Could you be more specific please. Thank you.Haematopoiesis
@SimonCorcos Sorry, I don’t have Visual Studio any more, I left Windows years ago – otherwise I would have written an answer. But I do remember that there are different runtime versions for C and C++ on Windows (besides the WinAPI) that the compiler links to – I think it was called MSVCRT. By default the compiler will link the most recent version but you can manually provide a command line argument to override that and link an older version (that you might have to download first, I don’t remember).Glottochronology
It's clear on the MSDN web site that no application from VS 2012 is going to work on Windows 95Haematopoiesis
@KonradRudolph, it was questionable whether VS 2012 was even going to be able to generate programs for Windows XP. See https://mcmap.net/q/1624327/-c-binary-doesn-39-t-work-on-windows-xpCrushing
@Mark Fair enough but I’ll note that (1) it’s a long shot from “not supported” to “does’t work” and (2) VS does (or at least did, at some point) support arbitrary compilers so you’re by no means married to msvc so if all else fails you can just use ICC or GCC (maybe even clang, no idea whether they care for Windows).Glottochronology
The mingw builds here claim: It can create 32-bit OR 64-bit binaries, for any version of Windows since Windows 95.. I've never targeted anything before xp though.Munson
@Jesse Good : Thanks! I'm downloading it right now. I'll test it and give you feed back asap.Haematopoiesis
@SimonCorcos : Out of curiosity, what's the business case for writing code for/supporting Windows 95?Degraw
possible duplicate of Developing programs for Windows 95 today?Bah
@Degraw : I work for a road construction company. They own asphalt plants, which generate data on their daily production. The computers that control these plants are sometimes very old (one of them still runs DOS). My C++ program extracts the data from a USB drive and send's it to a more modern machine where another program compiles the data and does stuff with itHaematopoiesis
C
3

First of all, why Windows 95? Well, anyway, you can use MinGW for that. Code::Blocks is my favorite IDE that's got MinGW. You can download it from here.

Censure answered 10/4, 2013 at 17:26 Comment(2)
This was already suggested in the comments. I'm installing Windows 95 on a VM right now to test the code. As for the why it's also in the comments.Haematopoiesis
@SimonCorcos Oh, I didn't read the comments. Anyway, Good Luck :)Censure
K
3

You need Visual C++ 2005 Express or Pro! It's the last version that'll support 95/98/ME. Anything newer will compile executables forcibly restricted to Windows XP-SP2 or above platforms.

You also have to mind the WinAPIs that you call as there are less of them available in 95, so you want to check with the MSDN library on everything you use to see if it's an original API that was available from day one (e.g. CreateFileA, ReadFile, CloseFile, etc.). I suppose if you code in ANSI "C" and use basic stuff you'll be OK, but it just depends.

FYI, the final MSDN library to complement a 2005 Visual Studio installation is "Microsoft Visual Studio 2005 (April 2007 Edition)" - you can find an ISO for that if you look, and Express was always free, just limited by the exclusion of a full graphical resource editor and other things.

Kirschner answered 28/5, 2016 at 4:39 Comment(3)
VC2005 will not target Windows 95 properly, you need 2003. If you tried to use 2005, at best you would get a failure to find IsDebuggerPresent() at startup, maybe more.Orometer
Hm, never had a problem. You gotta be careful with your Win32 API usage, make sure each one was introduced in Win95. Anything newer than VC++ 2005 for sure compiles EXE header settings that prevent it from executing. Also, it may be that I use my own lightweight CRT engine when I compile my EXEs that I learned about. Just checked MS API Docs, yes, IsDebuggerPresent() was introduced in Win98, you must stop it from being implicitly compiled/linked in! That's usually used to stop EXE tampering/cracking with a debugger in videogames.Kirschner
The other tip is use the LoadLibraryA/GetProcAddress for newer API functions to avoid implicit linking IF you really wanna keep the EXE/app backwards compatible. So from what you describe, too many built-in functions were used, and at some point, functions like IsDebuggerPresent() were implicitly linked without user control. You'd have to find out what C function actually needed that and replace it if possible.Kirschner
B
0

Download and install Pelles C v12. Break free of runtime dependencies and incompatibilities. Just be aware of the APIs you are calling and the supported releases of Windows for said APIs. I would never consult Visual Studio for this lol

Blancheblanchette answered 15/8, 2023 at 21:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.