Skip navigation

How to share Unix Executables???

557 Views 9 Replies Latest reply: Aug 10, 2013 4:48 AM by MrHoffman RSS
isiah1018 Level 1 Level 1 (0 points)
Currently Being Moderated
Aug 7, 2013 8:51 AM

I compiled c++ code in xCode and the program works fine.

 

To send it to another mac, i zipped the file, emailed it, and the other mac was able to open the zip and run the file no problem.

 

But how do I send it to a PC?

 

I tried emailing the file the same way as prev stated, then changing the extension FROM the PC to .exe and opening it with command prompt but I get "illegal action" error message.

 

 

Is there a way I can share my C++ program that runs in Terminal on my Mac, with a PC?

If so, how do I get it to run on the PC.

 

Thanks, Isiah.

  • xnav Level 5 Level 5 (6,615 points)
    Currently Being Moderated
    Aug 7, 2013 8:57 AM (in response to isiah1018)

    A C++ executable is not portable between Mac and PC.  You might be able to recompile the source on the PC and get it to work.

  • MrHoffman Level 6 Level 6 (11,695 points)
    Currently Being Moderated
    Aug 7, 2013 10:51 AM (in response to isiah1018)

    Most traditional programming languages and most compiled applications incorporate dependencies on the host operating system, make various calls to the host operating system, and even use data structures and formats within the executable file itself that are host-specific; executables are generally not portable. 

     

    This is the case across Microsoft Windows, Linux, OS X, Unix, OpenVMS, HP-UX, Tru64 Unix, Solaris, *BSD, and most any other operating system around.

     

    Most compilers — including C and C++, and Objective-C and Objective-C++ — do not generate portable executables.

     

    There are sometimes translation tools available that can allow the code to invoke the expected host operating system features on another platform (that's not the target operating system platform), but I'm aware of no tool for this particular porting situation.  An example of this approach is Wine, which allows some Windows executables to operate on Linux.  Again, there's no tool available to do this from OS X to Microsoft Windows AFAIK.

     

    Programming environments involving an interpreter such as Python, Lua, Java and Ruby — there are various other languages here, and the distinction between compiled and interpreter can be a little murky — generally can be packaged and transported and invoked on another target platform, so long as the dependencies are available on the target platform.  OS X includes Python and Ruby, and Java and Lua are available.

     

    Xcode can be used to maintain and build portable applications, but that's usually done with a command-line build or a build script (for Unix and Linux platforms), or using a tool such as make to sequence the compilation and linking.  Xcode can invoke those scripts, but those are created manually, and Xcode needs to be told to call the particular scripts and not its default build procedures.

     

    Porting and software portability are complex topics.

  • Michael Black Level 6 Level 6 (17,835 points)
    Currently Being Moderated
    Aug 7, 2013 10:53 AM (in response to isiah1018)

    There are open source C compilers for Windows (e.g. mingw, Microsoft Visual C++ express, Orange C).  Try one of those on the windows machine with your source code.

  • MrHoffman Level 6 Level 6 (11,695 points)
    Currently Being Moderated
    Aug 7, 2013 2:16 PM (in response to isiah1018)

    The Xcode documentation is probably your best resource for learning the tools.  Here's the Xcode user's guide (which doesn't cover using makefiles, but does introduce the tool) and here's a porting-related document in the Xcode documentation set, and look also around for what's called an "external build system" (In Xcode 4.6.3, see the doc for File > New > New Target > OS X, Other > External Build System) as well as the man pages for make and mkdep and probably a few other tools. 

     

    Beyond the Xcode documentation, if you're a member of the Apple developer programs, the developer forums and other developer resources and videos are a good resource for learning and for researching these sorts of questions.  There's also the Xcode mailing list.  There have been various discussions of connecting make and Xcode around the 'net, and probably in the mailing list archives, as well.

  • rccharles Level 5 Level 5 (5,140 points)
    Currently Being Moderated
    Aug 8, 2013 10:35 AM (in response to Michael Black)

    Michael Black wrote:

     

    There are open source C compilers for Windows (e.g. mingw, Microsoft Visual C++ express, Orange C).  Try one of those on the windows machine with your source code.

    What about gcc?

    http://gcc.gnu.org/

     

    Isn't gcc what xtool is using for the C++ compiler?  Best to use the same compiler in all environments.

     

    Robert

  • MrHoffman Level 6 Level 6 (11,695 points)
    Currently Being Moderated
    Aug 10, 2013 4:48 AM (in response to rccharles)

    rccharles wrote:

     

    Isn't gcc what xtool is using for the C++ compiler?  Best to use the same compiler in all environments.

     

    On OS X, any current Xcode version installs the llvm-clang chain including the lldb debugger, when the command-line tools are selected.

     

    The llvm compiler chain replaced gcc on OS X within Xcode for both C and C++ a while back, and gcc was deprecated.

     

    Having worked with both chains, I prefer clang to gcc for both for its integration with Xcode, and for its diagnostics.  I found lldb a bit rough early on, but it's working nicely now.

     

    Clang is available on various platforms beyond OS X, including Windows: Clang - Getting Started.

Actions

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.