Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11
Like Tree1Likes
I have a simple C program compiled in ubuntu and an excution file is produced. I wonder how can I put it in window and run it. Anyway can I ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jun 2011
    Posts
    10

    A beginner problem


    I have a simple C program compiled in ubuntu and an excution file is produced. I wonder how can I put it in window and run it. Anyway can I run this program in Window?



    Thank you.

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,517
    You can open a terminal window and run it there.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Just Joined!
    Join Date
    Jun 2011
    Posts
    10
    But can I run it in Window XP? I tried double click but it doesn't work

  4. #4
    Administrator jayd512's Avatar
    Join Date
    Feb 2008
    Location
    Kentucky
    Posts
    5,023
    Never tried doing that one, but you'll more than likely need a compiler for XP to run it.
    If you compile a program for one OS... that's what you gotta run it on.


    Somebody, please... correct me if I am wrong.
    Jay

    New users, read this first.
    New Member FAQ
    Registered Linux User #463940
    I do not respond to private messages asking for Linux help. Please keep it on the public boards.

  5. #5
    Just Joined!
    Join Date
    Jun 2011
    Posts
    10
    Thank you. I see the problem now. Any compiler that is suitable to compile a C program in Windows OS ?

  6. #6
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,380
    Disclaimer: I am not a developer.

    But for what itīs worth:
    Gcc has windows targets Host/Target specific installation notes for GCC - GNU Project - Free Software Foundation (FSF)
    There is gcc for windows included here MinGW | Minimalist GNU for Windows

    Probably it pays to use a native windows compiler, but this has for sure even more consequences in terms of platform independent coding.
    You must always face the curtain with a bow.

  7. #7
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    Just adding to what Irithori said, i use the GNU GCC compiler that comes with the Cygwin environment a lot and it usually works just fine (on simple C code). Note that this is not a trivial solution, you have to install the entire environment to use GCC, but if you (have to) do Linuxy stuff a lot in Windows, then I highly recommend Cygwin.

  8. #8
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,517
    No. Programs compile on Linux generally will not run in Windows. You can get the mingw gcc compiler for Windows and recompile it there in order to run it under XP.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  9. #9
    Just Joined!
    Join Date
    May 2011
    Posts
    4
    Quote Originally Posted by kelvin490 View Post
    Thank you. I see the problem now. Any compiler that is suitable to compile a C program in Windows OS ?
    Try DEVC++ Its free, download the installer from Bloodshed. Has the GCC and libs built in.

  10. #10
    Linux Enthusiast
    Join Date
    Jan 2005
    Location
    Saint Paul, MN
    Posts
    636
    Quote Originally Posted by kelvin490 View Post
    I have a simple C program compiled in ubuntu and an excution file is produced. I wonder how can I put it in window and run it. Anyway can I run this program in Window?



    Thank you.
    Due to differences in the OS API, Libraries, and binary format, a executable binary can not be run on Windows when compiled on Linux on Windows.

    However if the C program is written in ANSII C and you have a C compiler on Windows, you can transfer the source and build your program there and then execute.

    Note: The above was assume being on the same hardware. If different hardware, then recomiling is must even if using the same OS as the instructions understood by the processor are or may be different.

    Think about having a semi-truck load of stuff and then asking can I carry this load in Honda Insite? it just is not likely even of attempting to make multiple trips.
    jayd512 likes this.

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •