Thread: Help: how to compile a console application which can run pure Dos/Win32/Win64

  1. #1
    Registered User
    Join Date
    Feb 2008
    Location
    China
    Posts
    28

    Exclamation Help: how to compile a console application which can run pure Dos/Win32/Win64

    Hi friends, I am a freshman and would like to compile a console tool. Can any compiler(VC++ or Intel C++ or GCC) make a "console application" which can run Freedos/Win32 consile/Win64 console altogether? Thanks.

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    No, that's not how it works. When you compile a program using a compiler, it's made for a targetted system.

    For example, if you compile a program for DOS, it's a DOS program. It cannot be natively run on Windows XP nor Windows Vista If you compile it for Windows XP, it cannot be run on the other platforms natively. Even though a program runs in a black box that resembles DOS, it is NOT necessarily a DOS program.

    Part of the misconception of how everything works is how Windows XP and Vista manage to appear to actually run old programs. They do not actually run them as other programs. The old programs are actually run via emulation. This means your program may or may not work as intended if you run it in such a scenario. There is no guarentee that anything will work.

    Most or all compilers can produce a console program for their targetted environment, and if that is all you wanted to know, then the answer is pretty much yes.

  3. #3
    Registered User
    Join Date
    Feb 2008
    Location
    China
    Posts
    28
    But I really find some debug tools can run pure Dos and windows XP console at the same time!
    What are the key points to make such tools?

  4. #4
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    Such tools themselves are emulated themselves on newer platforms, and therefore as I said, they are not native to all platforms. They are not guarenteed to work.

    If you just want one program to appear to work on multiple platforms via emulation, do whatever you want, but don't expect anyone to be able to help you if you're trying to run a program compiled with an ancient compiler on a new machine.

  5. #5
    Registered User
    Join Date
    Apr 2006
    Posts
    2,149
    What MacGyver said is right. However you can still query what OS is being used and run the correct version based on that. Similar operating systems can run the same binaries, unless the application uses some version specific features. This means that you will have to make separate binaries for each supported OS for all your code; you'll have to compile for each OS separately.
    It is too clear and so it is hard to see.
    A dunce once searched for fire with a lighted lantern.
    Had he known what fire was,
    He could have cooked his rice much sooner.

  6. #6
    Registered User
    Join Date
    Feb 2008
    Location
    China
    Posts
    28
    Thanks MacGyver and King. By the way are you familiar with the "Emulatation" technology which is mentioned above?
    For example, if we would like to run a win32 console application under pureDos we can change the PE strcuture of the application.
    Last edited by chenayang; 07-13-2008 at 09:05 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Adding interface to Win32 console application
    By motiz in forum Windows Programming
    Replies: 5
    Last Post: 01-03-2008, 03:17 AM
  2. Saving a Console Application!!
    By ekweb in forum C++ Programming
    Replies: 10
    Last Post: 01-29-2006, 05:40 PM
  3. Console Application
    By Mont_Blanc in forum C++ Programming
    Replies: 3
    Last Post: 04-17-2004, 03:07 AM
  4. Just one Question?
    By Irish-Slasher in forum C++ Programming
    Replies: 6
    Last Post: 02-12-2002, 10:19 AM
  5. Replies: 4
    Last Post: 11-14-2001, 10:28 AM