Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

How to share Unix Executables???

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.

Posted on Aug 7, 2013 8:50 AM

Reply
9 replies

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.

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.

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.

How to share Unix Executables???

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.