LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 04-17-2008, 02:12 PM   #1
Micro420
Senior Member
 
Registered: Aug 2003
Location: Berkeley, CA
Distribution: Mac OS X Leopard 10.6.2, Windows 2003 Server/Vista/7/XP/2000/NT/98, Ubuntux64, CentOS4.8/5.4
Posts: 2,986

Rep: Reputation: 45
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?
 
Old 04-17-2008, 03:58 PM   #2
pljvaldez
Guru
 
Registered: Dec 2005
Location: Somewhere on the String
Distribution: Debian Squeeze (x86)
Posts: 6,092

Rep: Reputation: 269Reputation: 269Reputation: 269
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.
 
Old 04-17-2008, 04:41 PM   #3
jailbait
Guru
 
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Debian Wheezy, SolydK 2013
Posts: 7,435

Rep: Reputation: 134Reputation: 134
Quote:
Originally Posted by Micro420 View Post

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
 
Old 04-17-2008, 05:52 PM   #4
Micro420
Senior Member
 
Registered: Aug 2003
Location: Berkeley, CA
Distribution: Mac OS X Leopard 10.6.2, Windows 2003 Server/Vista/7/XP/2000/NT/98, Ubuntux64, CentOS4.8/5.4
Posts: 2,986

Original Poster
Rep: Reputation: 45
Quote:
Originally Posted by pljvaldez View Post
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 View Post
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.

Last edited by Micro420; 04-17-2008 at 05:53 PM.
 
Old 04-18-2008, 01:17 AM   #5
Micro420
Senior Member
 
Registered: Aug 2003
Location: Berkeley, CA
Distribution: Mac OS X Leopard 10.6.2, Windows 2003 Server/Vista/7/XP/2000/NT/98, Ubuntux64, CentOS4.8/5.4
Posts: 2,986

Original Poster
Rep: Reputation: 45
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!
 
Old 04-18-2008, 11:35 AM   #6
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,391
Blog Entries: 2

Rep: Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900
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.
 
Old 04-18-2008, 12:57 PM   #7
jailbait
Guru
 
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Debian Wheezy, SolydK 2013
Posts: 7,435

Rep: Reputation: 134Reputation: 134
Quote:
Originally Posted by Micro420 View Post
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
 
Old 04-19-2008, 07:25 AM   #8
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: FreeBSD, Debian, Mint, Puppy
Posts: 3,269

Rep: Reputation: 165Reputation: 165
isolate the non ANSI functions into seperate libs/files.
if they are simple try and find implementations of similar functions
or redo them yourself.
 
Old 04-19-2008, 07:36 AM   #9
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 62
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Porting C++ code from XP to Linux Bondfire Programming 7 08-12-2004 03:42 PM
Porting C++ code from windows to Linux ashwinipahuja Programming 9 06-03-2004 02:09 AM
Porting c++ code to linux Moons Programming 3 06-03-2004 01:24 AM
Porting C++ code from windows to Linux ashwinipahuja Linux - General 1 03-22-2004 02:57 AM
porting windows ce code to linux rainmann Programming 7 06-12-2003 07:19 AM


All times are GMT -5. The time now is 12:32 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration