Thread: Window to mac

  1. #1
    Registered User
    Join Date
    Sep 2009
    Posts
    5

    Window to mac

    So I have this program I coded out in C++; I normally compile it to an .exe, but my professor would like a copy of it and he uses mac. So how can i compile it to make it mac compatible. keep in mind i have to do this on a pca and have the program ready for mac. oh and i'm using code::blocks 8.02 with the GCC compiler, if that makes a difference
    Last edited by MilkyJoe; 09-28-2009 at 08:55 PM.

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    You don't. Just give him the source code. If it's written portably (eg: no Win32 API calls, for example - just pure ISO C++) it should compile on his machine without any problems.

  3. #3
    Deprecated Dae's Avatar
    Join Date
    Oct 2004
    Location
    Canada
    Posts
    1,034
    Can't he just install Mac OS X on VirtualBox, and compile it from within there? I don't know if that works, but from what I've read it should most of the time.

    Sure, he could give the source code if it was all standard C++, but something tells me it's not always that easy Professor might run into an issue compiling/linking (depending how complex) and decide not to be bothered with it.
    Last edited by Dae; 09-28-2009 at 09:53 PM.
    Warning: Have doubt in anything I post.

    GCC 4.5, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101

  4. #4
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    Perhaps your professor can run Virtual PC or other such emulation software instead.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  5. #5
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Just ask your teacher if he wants the code or if he wants an executable.
    If he says he wants an executable, ask if he as a mac that you can borrow.
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

  6. #6
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    Can professors have multiple OS and save the trouple? It is not that they take that much space in the HD. Not decades to boot either

  7. #7
    Registered User
    Join Date
    Sep 2009
    Posts
    5
    So there's no way to compile it for him on my pc so he can run it on his mac?

  8. #8
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    Quote Originally Posted by MilkyJoe View Post
    So there's no way to compile it for him on my pc so he can run it on his mac?
    Not easily. There is probably a cross compiler for Mac out there that runs on Windows, but setting up cross compiler toolchains is not a trivial task.
    bit∙hub [bit-huhb] n. A source and destination for information.

  9. #9
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Quote Originally Posted by MilkyJoe View Post
    So there's no way to compile it for him on my pc so he can run it on his mac?
    A compiler turns source code into a stream of machine code instructions targeted for a certain CPU. For PC's, this means x86 opcodes. Moreover, it structures everything into an executable format compatible with a certain platform. Under Windows, this is usually the Portable Executable (PE) format. Mac uses an entirely different instruction set and file format. So to get the former to work with the latter, you'll need some sort of 'emulator' that can run a Windows binary inside of a 'virtual machine', or else some sort of converter that can translate it to a Mac binary. So in a nutshell, giving him the source code would be the easiest option. If he doesn't have much experience with compilers, just put together a 'make' file and step-by-step installation instructions, to make it easier. Or perhaps borrow a Mac from a friend, or such, and just compile it for him.

  10. #10
    Deprecated Dae's Avatar
    Join Date
    Oct 2004
    Location
    Canada
    Posts
    1,034
    Quote Originally Posted by MilkyJoe View Post
    So there's no way to compile it for him on my pc so he can run it on his mac?
    Options:

    1) Create a project folder, add makefile, add source code. Include Mac version of gcc compiler beside project folder. Have him build it himself.

    2) Borrow a mac, or find a mac (bring the code on usb/disc), or ask professor to use mac, etc.

    3) Ask professor if he could dual-boot Windows (install windows) because really, if this professor's field has anything to do with computers he should have Linux, Windows, and Mac.

    4) Bring VirtualBox (VirtualBox) on usb/disc, and a copy of Windows iso (get it from professor if you don't own one). He can use Windows from inside Mac and should be able to run your program (very few don't work - usually intensive graphics apps).

    5) Bring Wine (WineHQ - Run Windows applications on Linux, BSD, Solaris and Mac OS X) on usb/disc (dont need iso), and he should be able to run your program (some don't work - you might want to test it yourself from linux Wine).

    6) Download VirtualBox, run Mac OS X from inside your Windows, and compile it there. This seems common. Mac's are on x86 architecture now and VirtualBox settings should match your professors real Mac in most cases, allowing him to run it natively.

    7) Try to find a cross-compiler, so it automatically builds binaries for different platforms, but they seem to suffer from many issues.

    Good luck.
    Warning: Have doubt in anything I post.

    GCC 4.5, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101

  11. #11
    Registered User
    Join Date
    Sep 2009
    Posts
    37
    u can use a crosscompiler wich can compile for MAC just take a look at sourceforge ther should be one

  12. #12
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    8) Ask professor

  13. #13
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Quote Originally Posted by C_ntua View Post
    8) Ask professor
    Hehe. Indeed.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C or C++
    By AcerN30 in forum Game Programming
    Replies: 41
    Last Post: 05-30-2008, 06:57 PM
  2. Just starting Windows Programming, School me!
    By Shamino in forum Windows Programming
    Replies: 17
    Last Post: 02-22-2008, 08:14 AM
  3. WM_CAPTION causing CreateWindowEx() to fail.
    By Necrofear in forum Windows Programming
    Replies: 8
    Last Post: 04-06-2007, 08:23 AM
  4. 6 measly errors
    By beene in forum Game Programming
    Replies: 11
    Last Post: 11-14-2006, 11:06 AM
  5. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM