Thread: mac+windows app

  1. #1
    Registered User
    Join Date
    Jun 2008
    Posts
    266

    mac+windows app

    Is it possible to make an application that works on both windows and mac without being recompiled for each OS?

  2. #2
    Registered User
    Join Date
    Jun 2008
    Posts
    22
    Yes, I believe so. I think you can use this. It's Trolltech's Qt application: http://trolltech.com/products/qt/. But I think you can only do so much. I'm not sure though. Hope this helps though.

  3. #3
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Is it possible to make an application that works on both windows and mac without being recompiled for each OS?
    With respect to C++, the answer is generally no.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  4. #4
    Registered User
    Join Date
    Jun 2008
    Posts
    266
    How about windows and unix/linux?

  5. #5
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    No. Windows and Linux have different executable formats.
    Besides that, it is highly unlikely that something compiled for one platform will work on another (technically, it's possible, but it's darn difficult, and I doubt anyone has done it or will).
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #6
    Registered User
    Join Date
    Jun 2008
    Posts
    127
    i was just curious because i saw the pro version of limewire where they claimed it was compatable for windows, linux, and mac.
    http://www.limewire.com/download/

  7. #7
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    i was just curious because i saw the pro version of limewire where they claimed it was compatable for windows, linux, and mac.
    The question is not whether it is possible to write a program that runs on both Windows and Mac, but whether it is possible to write a program that runs on both Windows and Mac without compiling for each platform.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  8. #8
    Registered User
    Join Date
    Jun 2008
    Posts
    127
    yes i understand the question. at the top right corner where it is listing the benifits of limewire pro it states it is windows, mac, and linux compatible.

  9. #9
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Have a look at their download links again. There are 4 different versions, not one.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  10. #10
    Registered User
    Join Date
    Jun 2008
    Posts
    127
    i am aware of that but the PRO version specs at the top say it supports all three OS's

  11. #11
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Yes -- but that just says they have a version on the OS's. The three files are NOT bit-for-bit equivalent.

  12. #12
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Irrelevant. There are 4 different versions. Each one compiled for their specific platform.
    There is no way, with C++, that you can get the same executable running on both Windows and Linux and Mac.
    They use different executable formats! It just won't run. OS Limitation.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  13. #13
    Registered User
    Join Date
    Jun 2008
    Posts
    127
    you guys are just jealuos of my sweet c++ knoledge.RARRRRRRRRR

  14. #14
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by herWter View Post
    you guys are just jealuos of my sweet c++ knoledge.RARRRRRRRRR
    That dinosaur you do is just so darn cute I can't stand it.

  15. #15
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    There are a few things that need to match if you want to write a compiled [1] application that runs on different platforms:
    • All systems must support the same file-format. Windows uses something called PE-COFF. Linux generally use ELF but also has a "a.out" format. I think ELF is also the format for the recent versions of MacOS (v10+ that is based on a BSD Unix type kernel). Older MacOS is using a different [I think proprietary format].
    • All systems must support the same instruction set. That means that the Mac model must have a x86 processor to be compatible with a x86 version of Linux or Windows - or the processor will be just as wise as I am when a french person speaks his/her native language with me - that is, I haven't got a clue. [2]
    • All systems must support the same API/ABI. API stands for Application Programming Interface, ABI is Application Binary Interface. The API says "these are the functions we can use in this OS, and this is what you can expect from the function [including what happens if you pass in 'bad' parameters - e.g. a filename that doesn't exist to a OPEN FILE function]". The ABI tells the (system)programmers how "stuff" is passed from one function to another within the system, e.g. a function that returns an integer does so in register X, arguments to functions are passed in registers Y and Z and then on the stack [the stack is in register W], etc, etc.


    There are some ways around all/some of these things. We could for example have our own generic ABI/API combination for our application, and then have three sets of ABI/API interface files that translate our internal ABI/API combo into the particular systems ABI/API - so "genericOpenFile" translates to Windows "OpenFile", and "open" in Linux/MacOS.

    We would also have to build a system-specific loader that loads our generically supported file-format. So in Windows, we'd have something that uses VirtualAlloc() to allocate memory for the appliction to run in, and then load the code into the allocated memory.

    It is possible to do, but it gets very hard if you want to support generic functionality, because there are usually differences in how the different OS's support something, and they are so different that you have to use a different overall principle to solve the same problem in two different OS's [a typical example is "fork()" which doesn't have an equivalent in Windows at all - it would be possible to fake a fork(), but it's quite complicated and it's very easy to "miss something" so that it's no longer doing the exact thing the coder wanted].


    [1] It is of course much easier to have the same code work on different platforms if it's compiled into a form that isn't actually machine code for the target system.

    Other languages, such as C# and Java have solutions do this. In Java it's pretty good, but I have a feeling that C# is fairly limited in what you can actually do if the system isn't running on Windows.

    Unfortunately, this also means that there's a performance loss compared to natively compiled applications. It is possible to "compile as we go along" into machine code, but it is still quite hard to get that to run as fast as a native application, because some of the original context of what was actually being the code has been lost in the intermediate translation - a bit like translating something from english to spanish, but because we couldn't find a good english to spanish translator, we take the french translation and translate that to spanish - some of the original "flavour" of the language has now been lost.

    [2] There have been systems (e.g. MacOS systems) that support older applications compiled for a processor that is different from the current processor, e.g. running 68000 based code on PowerPC and running PowerPC on x86 processor. This is however not a particularly good solution for high performance operations.
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to Send Mac Address From Client to Server
    By Lieyza197 in forum C Programming
    Replies: 2
    Last Post: 05-27-2009, 09:58 AM
  2. Windows Form App as parent, Directx as child??
    By yetti82 in forum C++ Programming
    Replies: 3
    Last Post: 05-29-2006, 03:04 AM
  3. Question..
    By pode in forum Windows Programming
    Replies: 12
    Last Post: 12-19-2004, 07:05 PM
  4. FlashWindowEx not declared?
    By Aidman in forum Windows Programming
    Replies: 3
    Last Post: 05-17-2003, 02:58 AM
  5. Multiple threads, Dos APP, manage windows
    By cbrc00f in forum C Programming
    Replies: 1
    Last Post: 04-15-2003, 06:21 AM