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

Standalone C-code

I hope someone can help me with running some simple C-code outside of XCode once it compiles and runs? I want to give only the result, or executable, file to someone so they can only see the operation of a C-based program. I don't want them to see the actual code, but its operation. Thank you for all of your help!!!


#include <stdio.h>


int main(int argc, constchar * argv[])

{

printf("Just want the output to be displayed and not the code when the program is launched outside of XCode.");

return0;


}

Posted on May 7, 2013 4:40 PM

Reply
8 replies

May 7, 2013 6:44 PM in response to Conundrum

If it is a simple c program the easiest thing to do is once you compile the program in Xcode open the Products folder, select the file shown there (the executable of your code) and right click it and select show in finder.


When the finder window opens drag the file to the Desktop and you will have the executable. Open a Terminal window, cd to the Desktop and run the file.


User uploaded file

May 8, 2013 5:38 AM in response to Conundrum

You can't. The executable is compiled for a specific type of OS system. To compile code to execute on a windows machine you will need to compile on a windows machine.


There are things called cross compilers that are capable of creating executables on one system that run on another but I'm not aware of any for OS X to Windows compilation.


regards

May 8, 2013 10:27 AM in response to Conundrum

> ... some simple C-code outside of XCode once it compiles and runs? I want to give only the result, or executable, file to someone so they can only see the operation of a C-based program. I don't want them to see the actual code, but its operation.


There is a *huge* difference between "C code" and "executable code". As soon as it is compiled, you cannot 'see' the source anymore -- it's no longer "C code", it has been compiled into "executable" code. That is, as Frank says, extremely OS-specific.


> ... Your solution to my issue will only work if the person has a Mac or UNIX on their computer ...


Not on UNIX. Not even all "Macs" will run your code. Some parts of your code may depend on system libraries that are only available on the actual system you compiled it on. Newer version may be able to work with it, but older versions of OS X (the proper name for what you call "Mac") may not.


The only way to provide your program to Unix-based systems as well as Windows is to provide separately compiled executables. (With the proviso that for those you are also bound by some lower limit of the target OS versions.)

Standalone C-code

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