6

I am using Xcode to do C++ programming but the problem is when i build the program it doesnot creat a executable file like Turbo C++ creates a .exe file. What can i do to create such executable file on OS X environment using xcode.?

2
  • Perhaps this article could help you. Commented Jan 26, 2016 at 14:18
  • @SaschaM78, consider paraphrasing the linked article and turning it into an answer :) Commented Jan 26, 2016 at 14:49

4 Answers 4

11

Follows this: File->Project Settings->under Derived Data, Click the Advanced->Click Custom, then choose the option Relative to Workspace->Done. Then build your code and you will see Product file package in your project path. I am using Xcode 8.2.1, hope it may help.

Sign up to request clarification or add additional context in comments.

1 Comment

It worked for me (Xcode 15.4). This is the real answer to the question.
1

I'll try to summarise the following article and hope it'll help you get started:

How To: Compile and Run Basic C++ Programs in Xcode

  1. Start a new project: select File, New Project
  2. in the Application dropdown, pick your desired application type (i.e. "command line utility") and choose "C++ Tool"
  3. choose a location (and remember the path for later) and click Finish
  4. Start coding your application
  5. when you are done, click on the Build button
  6. now Finder and navigate to the project folder that you picked in step 3
  7. in it, you should find a file with the name of your project without any extension
  8. double click the file et voilà, your application should starts (in the example above, a terminal window should appear)

Let me know if it helped you solve your problem.

1 Comment

as you said there appeared a file with name of my project but when i double clicked the file .. it again opened xcode not the terminal window... please help me out
1

I got a simple solution for you got Product > archive and select distribute content and use the build option. Dig deep into the folder created and you can find the Mac executable file that'll run almost on any Mac.

1 Comment

Why is this so hard? Building an executable should be the easiest thing a compiler/linker does. Hmmm.
0

you need to find the working directory of Xcode.

If you are working with C/C++, type system("pwd"); in your main function. This will print your working directory. In which you shall find the executable.

(I am not sure about other languages but there must be a substitute for system()).

your output should look something like this: /Users/your_username/Library/Developer/Xcode/DerivedData/Build/Products/Debug

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.