LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Porting DOS program to Linux. I have the C source code ... (https://www.linuxquestions.org/questions/programming-9/porting-dos-program-to-linux-i-have-the-c-source-code-636056/)

Micro420 04-17-2008 02:12 PM

Porting DOS program to Linux. I have the C source code ...
 
I got put in charge of this DOS program. I have the source code written in C, but when I use gcc, I get these errors about the header files missing:
Code:

gom3.c:8:17: error: dos.h: No such file or directory
gom3.c:9:17: error: dir.h: No such file or directory
gom3.c:10:19: error: alloc.h: No such file or directory
gom3.c:13:17: error: mem.h: No such file or directory
In file included from gom3.c:15:
standard.h:4:16: error: io.h: No such file or directory
standard.h:5:19: error: conio.h: No such file or directory
standard.h:11:22: error: sys\stat.h: No such file or directory
standard.h:12:19: error: share.h: No such file or directory

Those look very DOS specific. Any way I can get them or substitute for them?

pljvaldez 04-17-2008 03:58 PM

Do you need to port the program, or would it be acceptable to use dosbox or FreeDos to run the program in a virtual machine?

I'm not a programmer, so I'm just sort of thinking outside the box.

jailbait 04-17-2008 04:41 PM

Quote:

Originally Posted by Micro420 (Post 3124433)

Code:

gom3.c:8:17: error: dos.h: No such file or directory
gom3.c:9:17: error: dir.h: No such file or directory
gom3.c:10:19: error: alloc.h: No such file or directory
gom3.c:13:17: error: mem.h: No such file or directory
In file included from gom3.c:15:
standard.h:4:16: error: io.h: No such file or directory
standard.h:5:19: error: conio.h: No such file or directory
standard.h:11:22: error: sys\stat.h: No such file or directory
standard.h:12:19: error: share.h: No such file or directory

Those look very DOS specific. Any way I can get them or substitute for them?

Glibc has header files which perform similar functions. You can make sure that all of your function calls follow the glibc format and then substitute the glibc headers for the DOS headers.

http://www.gnu.org/software/libc/man...tml#toc_Memory

For example, here is the description of the malloc call which is found in header stdlib.h

http://www.gnu.org/software/libc/man...sic-Allocation

------------------
Steve Stites

Micro420 04-17-2008 05:52 PM

Quote:

Originally Posted by pljvaldez (Post 3124527)
Do you need to port the program, or would it be acceptable to use dosbox or FreeDos to run the program in a virtual machine?

I'm not a programmer, so I'm just sort of thinking outside the box.

I did try the program using FreeDOS and DOSbox, but unfortunately the performance is VERY poor. In fact, this DOS program ran faster in Windows Vista!

Quote:

Originally Posted by jailbait (Post 3124567)
Glibc has header files which perform similar functions. You can make sure that all of your function calls follow the glibc format and then substitute the glibc headers for the DOS headers.

http://www.gnu.org/software/libc/man...tml#toc_Memory

For example, here is the description of the malloc call which is found in header stdlib.h

http://www.gnu.org/software/libc/man...sic-Allocation


Thanks, I will check out those headers and see if it can work. I'm not really that familiar with C programming so I will have more questions.

Micro420 04-18-2008 01:17 AM

Alright, this seems too messy for me. I need specific header files, and without them, certain functions in the code don't work because they depend on those headers. It would require a lot of rewriting of the code and cleaning up to make it work with gcc. Looks like it's time to pay a professional programmer to do this!

theNbomr 04-18-2008 11:35 AM

The header files conio.h & dos.h contain declarations of functions which are very DOS-specific. You will need to figure out how to achieve the functionality that these provide using only Linux style functions or systems calls. DOS C compilers played fast and loose with real-mode capabilities, which do not exist in a protected-mode OS.
--- rod.

jailbait 04-18-2008 12:57 PM

Quote:

Originally Posted by Micro420 (Post 3124889)
Alright, this seems too messy for me. I need specific header files, and without them, certain functions in the code don't work because they depend on those headers. It would require a lot of rewriting of the code and cleaning up to make it work with gcc. Looks like it's time to pay a professional programmer to do this!

Right.

--------------------
Steve Stites

bigearsbilly 04-19-2008 07:25 AM

isolate the non ANSI functions into seperate libs/files.
if they are simple try and find implementations of similar functions
or redo them yourself.

matthewg42 04-19-2008 07:36 AM

Is it a small program?

Can you (and are you willing) to publish the code under an open source license?

What does it do?

Depending on the answers to these questions, you might find random coders out there willing to help for no money.


All times are GMT -5. The time now is 08:50 AM.