Solved

Recompile a DOS C program to MS Visual C++ for Windows 7 (or 10)

Posted on 2016-09-27
11
57 Views
Last Modified: 2016-11-08
Greetings all,

Due to a contract restart, I have to update, compile and run a DOS C program on WIndows 7 computers.  

I have the C code in a text file.  When I have tried running the utility under compatibility mode, I get the following error: "This version of the file is not compatible with the version of Windows you're running.  Check your computer's system information to see whether you need an x86 (32-bit) or x64 (64-bit) version of the program, and then contact the software publisher."

Is there a simple way to copy and paste the C code into Visual C++ 2015 and target the compilation to WIn 7 which acts like DOS?

The DOS utility generates the burn file for PROMs and also the documentation files for the PROMs.

I would imaging that the execution of the utility under Win 7 would simply open a Command Prompt like window which would act like a DOS screen.  There should be no real issue in writing the documentation files as they are simply text files.

Any suggestions greatly appreciated.

Mark
0
Comment
Question by:TMarkB
  • 3
  • 2
  • 2
  • +2
11 Comments
 
LVL 40

Assisted Solution

by:evilrix
evilrix earned 166 total points
Comment Utility
Well, Visual Studio 2015 (which is free) does allow you to build DOS applications; however, it doesn't support some of the older DOS stuff and may not have all the headers or libraries you need. The best thing is to suck it and see. Just download and install VS2015. Create a new DOS project, copy the code into the project and try building it with default settings. Unfortunately, that really is about the best you can do. If you get build errors let us know what they are. If the source code isn't too large and you don't mind sharing it with us we could have a go and trying to build it for you.
0
 
LVL 68

Assisted Solution

by:Qlemo
Qlemo earned 83 total points
Comment Utility
The error message probably results from a 16bit DOS program started on a 64bit OS. You can try if it runs on a 32bit W7, that might be the most simple approach.

If there is no hardware access required, you should be able to compile the old code in VS 2015 as a console application. But it might require to fiddle with some options.
0
 
LVL 23

Assisted Solution

by:Dr. Klahn
Dr. Klahn earned 83 total points
Comment Utility
If this is a one-shot, I'd buy an old laptop with Windows 95 or Windows NT V4.  That's about as close to real DOS as possible without going back to Windows 3.1.  Put an old copy of Borland C or Visual C on it, and use that for the project.  Then when done, zip it up into a case, give it to the customer with your compliments, and say "Don't lose this, it's the only system in the world that can update your PROMs."
0
 
LVL 40

Assisted Solution

by:evilrix
evilrix earned 166 total points
Comment Utility
The last version of Visual Studio that can build true DOS is 1.52, and finding a legitimate copy of that is like finding hen's teeth, so I don't think that is a realistic option. The problem here isn't the version of Windows, it's the version of the compiler.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 82

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 168 total points
Comment Utility
MinGW based on the Linux / Unix compilers may be an option for you.  Included are C, C++, and some other compilers.  http://www.mingw.org/
0
 

Author Comment

by:TMarkB
Comment Utility
Just to clarify, the intention is to take C code and recompile to run on WIN 7 or WIN 10.  Unfortunately, this is not a one time use.  I will be needing to use this a couple more times in the future.
0
 
LVL 40

Expert Comment

by:evilrix
Comment Utility
Okay, so have you tried using Visual studio 2015 (the community edition is free and can be used to create software for distribution without any licencing concerns) as I suggested?
0
 

Author Comment

by:TMarkB
Comment Utility
Greetings all... any suggestions on how to proceed greatly welcomed.

The good news was that Visual Studio 15 does allow importing of older C code.

Now for the bad news:

I took a look at the obj file and found out that it was compiled using TC86 Borland Turbo C++ 3.00.

The bad news is that Visual Studio 15 apparently has no clue what to do with the C preprocessor directives.

The following does not seem to have meaning even though I thought these were common across platforms:
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
#include<time.h>

Visual Studio 15 doesn't know where to look to get these.

As a result, when using a line like:
now = time(NULL) ... A error on the NULL appears.

I took a look at trying to create a console program.  VS15 immediately forces you into the C++ CLASS model.  There do not seem to be an option in using simple basic C from days of old.

Any suggestions on how to recompile a C code into Windows 7??

Are there any current era C windows C (not C++) compilers on the market that run under Windows 7?

Thanks
0
 
LVL 82

Accepted Solution

by:
Dave Baldwin earned 168 total points
Comment Utility
MinGW based on the Linux / Unix compilers may be an option for you.  Included are C, C++, and some other compilers.  http://www.mingw.org/  It's free.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now