Thread: Is there a program/compiler to write C++ for linux on windows?

  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    184

    Is there a program/compiler to write C++ for linux on windows?

    I know that Linux has programs so you can use a Linux OS and compile C++ code for a windows environment. Is there such a thing in the reverse?

  2. #2
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Chappell Hill, Texas
    Posts
    2,332
    Wine perhaps?
    Mainframe assembler programmer by trade. C coder when I can.

  3. #3
    Registered User
    Join Date
    Oct 2006
    Location
    Omaha, Nebraska
    Posts
    116
    gcc allows for cross compilation. not sure how well it works but you can check the man pages for how to do it.

  4. #4
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    you can just run a linux envirounment on windows - for example using andLinux distro - you get fully functional linux install running inside "windows window"
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  5. #5
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by 6tr6tr View Post
    I know that Linux has programs so you can use a Linux OS and compile C++ code for a windows environment. Is there such a thing in the reverse?
    You would need a cross compiler and a cross toolchain. I've never tried this (built a cross-cc from Windows to Linux), but if I did, I would use Cygwin as a base on Windows, then install a cross-binutils for Linux ELF, then install a cross-gcc. Before installing the cross-gcc you will have to copy all the system header files and libraries from the Linux system to a location where cross gcc can find them. There is a cross compiler FAQ for gcc you will have to refer to.

    EDIT: One thing I have done, it translated Windows .obj files to Linux ELF .o files, then done the linking step on Linux. This lets you do the sick thing of compiling Linux programs using Visual Studio. Provided there's nothing "weird" happening in your .obj files, I remember the process being smooth enough to be workable. Kind of pointless however.

  6. #6
    Registered User
    Join Date
    Apr 2008
    Location
    New York
    Posts
    9
    Cygwin, I think is the most easy to learn Unix environment for windows. It's probably the best solution.

  7. #7
    Registered User guesst's Avatar
    Join Date
    Feb 2008
    Location
    Lehi, UT
    Posts
    179
    Okay, very interested in this. That way I can run programs myself and not rely on the charity of others.
    Cygwin is not a way to run native linux apps on Windows. You have to rebuild your application from source if you want it to run on Windows.
    but andLinux is? Wouldn't that make andLinux better?

    I'm actually thinking a dual boot. What is the defacto norm for Unix now-a-days?
    Type-ins are back! Visit Cymon's Games at http://www.cymonsgames.com for a new game every week!

  8. #8
    Registered User
    Join Date
    Nov 2006
    Posts
    184
    Thanks for the replies. Since I have MinGW/GCC already I'll start looking into that. But I can also the benefit of having linux running in Windows to try it out quickly too. Any other suggestions?

  9. #9
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Any of the Virtulization products (Xen, VMWare and several others) will allow you to run multiple instances of OS's on the same machine at the same time [I believe "andLinux" uses some similar techniques to make Linux run on top of Windows - but I'm not sure].

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  10. #10
    Alessio Stella
    Join Date
    May 2008
    Location
    Italy, Bologna
    Posts
    251
    the situation seems very complex here

  11. #11
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    I'm not sure it's that difficult. You just need to build gcc for cross-compilation, then build the binutils for cross-compilation. Once you have done that, you need to compile (or copy) the Linux C and C++ libraries.

    I'm pretty certain gcc-mingw can be used to compile gcc and binutils to produce Linux code.

    It is no more strange than using gcc to compile code for ARM or MIPS on a PC.

    You may need to have to work a little bit with getting "./configure" to run on a Windows system, but other than that it's not that hard.

    Of course, the next problem is testing the code - if you haven't got a Linux machine to test on, then you wouldn't know if your newly compiled code works or not.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  12. #12
    {Jaxom,Imriel,Liam}'s Dad Kennedy's Avatar
    Join Date
    Aug 2006
    Location
    Alabama
    Posts
    1,065
    Slax would be a viable alternative to building a cross tool chain. . . especially since Wall-mart has 8GB jumpdrives for $20. . . There are ways to install a full blown install with it.

    $0.02

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how to make a windows application
    By crvenkapa in forum C++ Programming
    Replies: 3
    Last Post: 03-26-2007, 09:59 AM
  2. Replies: 6
    Last Post: 01-01-2007, 07:36 AM
  3. Question..
    By pode in forum Windows Programming
    Replies: 12
    Last Post: 12-19-2004, 07:05 PM
  4. Manipulating the Windows Clipboard
    By Johno in forum Windows Programming
    Replies: 2
    Last Post: 10-01-2002, 09:37 AM
  5. How come this only works in Windows nt/2000?
    By Unregistered in forum Windows Programming
    Replies: 1
    Last Post: 08-30-2002, 06:54 PM