Compiling for Windows under OS X (C++)

Discussion in 'Mac Programming' started by djcraze, Aug 27, 2009.

  1. djcraze macrumors regular


    Jul 3, 2007
    I'm taking a C++ class for my Computer Science degree.. and of course my instructor wants me to compile for Windows. Is there a program that can do this? (I don't want to use CrossOver or VMWare, etc)

  2. Guiyon macrumors 6502a

    Mar 19, 2008
    North Shore, MA
    Depends on the APIs. If you're sticking with mostly open source or POSIX based APIs you may be able to setup a MinGW environment from source so you can cross-compile to a Windows executable which, in my opinion, is going to be more trouble than it's worth. If you are going to be using Windows APIs then you really have no choice; you will need to use an actual Windows install. In either case, it may be a wise idea to check with your IT department as they may be licensed to give you a key for Windows and the Visual Studio SDK. At that point you can either download VirtualBox and run a VM or just install Windows via Bootcamp (both are free options).
  3. djcraze thread starter macrumors regular


    Jul 3, 2007
    it has nothing to do with Windows APIS :). its VERY basic C++. Beginners. I could easily compile the stuff were doing for OSX.

    I'm compiling basic .cpp files..
  4. Tallest Skil macrumors P6

    Tallest Skil

    Aug 13, 2006
    1 Geostationary Tower Plaza
    So it's just command-line stuff. Your professor will probably want your code itself and not the finalized compiled program. At least mine didn't. I was able to write and compile (to check integrity) with Xcode and just submit the C++ file straight off. If he wants the final compiled program... that's not good teaching, really.
  5. djcraze thread starter macrumors regular


    Jul 3, 2007
    I agree, I think he wants both though. To be honest I'm not 100% sure. He has yet to upload the assignments to evil blackBoard. Eitherway, lets assume he wants them both.
  6. autorelease macrumors regular

    Oct 13, 2008
    Achewood, CA
    Do you have access to a computer lab with Windows machines? They'd probably have Visual Studio or Cygwin and GCC. In that case, just write your assignment on your Mac, then, before you hand it in, compile and test it on a lab machine.

    When I took C courses in college, even though our assignments were simple command-line programs, we had to make sure they worked on Windows, Linux, and Solaris. It's always good to be safe--there are some extremely subtle cross-platform differences that could bite you in the, um, rear. :p
  7. bkap16 macrumors member

    Jan 11, 2009
    If your objection to CrossOver is the cost and not the concept, you can always use Wine ( which is the open source project CrossOver is based off of. You'll probably want either macports or fink to install it since they don't make Mac binaries.
  8. gnasher729 macrumors P6


    Nov 25, 2005
    Can't you just ask him? Like "I have a Macintosh with XCode. How do you think I should compile for Windows? "
  9. newb16 macrumors regular

    Feb 27, 2008
    Once there was a 'crosscompilerforwin32' page on, that was a mingw hosted on mac os, but it's no longer available.
  10. mslide macrumors 6502a

    Sep 17, 2007
    You can try this if you want to setup a cross compiler environment on your mac. It's mingw built for a mac.

    I'd ask your teacher exactly what he wants. If he wants a windows binary, does he care how you built it (Visual Studio, cygwin/gcc, mingw)? Personally, I'd setup mingw & msys under windows inside a VM. I'd do all the development/testing/debugging on my mac and then build it and test it on windows just to make sure it does work on it.
  11. Eraserhead macrumors G4


    Nov 3, 2005
    I've just checked and you can't run Visual Studio on Wine, so I suggest you get a PC to do the final code test, or use a PC in the lab.
  12. krayziekray macrumors 6502

    Sep 24, 2008
    Mate I would suggest using a VM to install Windows, and do your coding from there. Though it may be very basic C++, you may still need access to windows header files (windows.h) etc.

    :apple: KrayzieKray :apple:

Share This Page