Running The HelloWorld App in Windows

This is a discussion on Running The HelloWorld App in Windows within the C Programming forums, part of the General Programming Boards category; Hi guys i'm new to C, and I tried compiling the HelloWorld application. Code: #include <stdio.h> main() { printf("\n\nHello World\n\n"); ...

  1. #1
    Young C n00b
    Join Date
    Jul 2006
    Posts
    59

    Running The HelloWorld App in Windows

    Hi guys i'm new to C, and I tried compiling the HelloWorld application.

    Code:
    #include <stdio.h>
    
    main()
    {
    
    printf("\n\nHello World\n\n");
    
    }

    In a linux environment, I compiled with the command:

    Code:
     gcc HelloWorld.c
    The file compiled successfully and I got a file, "a.out". I executed the file and it worked.

    I again compiled the file, but with the -o option, so that I could get an .exe file.

    Code:
     gcc HelloWorld.c -o HelloWorld.exe
    I then transferred HelloWorld.exe to my desktop on my windows platform, and tried to execute it in the windows environment.
    Upon execution, a terminal window popped up, and did nothing. No text was displayed.

    How do I make a windows-compatible executable? Am I missing any options to include with the compiler?
    Last edited by kwikness; 07-29-2006 at 10:42 AM.

  2. #2
    1 == 1 tzpb8's Avatar
    Join Date
    Jul 2006
    Posts
    36
    I dont know much about linux but if you write it correctly maybe it will workout so here is what you can try to compile it as:
    Code:
    #include <stdio.h>
    
    int main(void)
    {
    
    printf("\n\nHello World\n\n");
    
    return 0;
    
    }
    You can make windows executables (for xp pro atleast) with Dev-C++.
    Get it from here.
    Last edited by tzpb8; 07-29-2006 at 10:53 AM.

  3. #3
    Registered User
    Join Date
    Aug 2003
    Posts
    1,203
    If i remember correctly you can not compile something under one OS and expect it to work under another OS, unless the compiler is specifically created to do just that.
    STL Util a small headers-only library with various utility functions. Mainly for fun but feedback is welcome.

  4. #4
    Young C n00b
    Join Date
    Jul 2006
    Posts
    59
    thx Shakti, i downloaded cygwin and compiled with that. The file works in windows.

    I was under the impression that C is almost always compiled on a linux box, even if it's being designed for a windows platform.

    Does anyone know if it's possible to make a windows compatible .exe with the GCC compiler in linux?
    If so, how?

  5. #5
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,496
    Such things are called cross-compilers.
    http://www.mega-tokyo.com/osfaq/GCC%20Cross-Compiler

    It's a fairly esoteric thing to want to do, especially since there are plenty of hosted compilers for windows anyway.

    One of the easier routes might be to run either Dev-C++ or MinGW under Wine on your Linux Box.

    > I was under the impression that C is almost always compiled on a linux box,
    > even if it's being designed for a windows platform.
    Never heard of that one before.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 12-22-2006, 07:45 PM
  2. Windows App a few problems
    By curlious in forum C++ Programming
    Replies: 2
    Last Post: 10-21-2003, 04:10 PM
  3. Multiple threads, Dos APP, manage windows
    By cbrc00f in forum C Programming
    Replies: 1
    Last Post: 04-15-2003, 06:21 AM
  4. newbie question about using windows app in Dev C++
    By Unregistered in forum C++ Programming
    Replies: 2
    Last Post: 06-09-2002, 10:50 PM
  5. Turning a Console APP into Windows.
    By Darkflame in forum C++ Programming
    Replies: 3
    Last Post: 09-14-2001, 03:10 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21