Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run C program in Xcode 4 using makefile

I have created an 'External Build Project' in Xcode 4 using a makefile. The project builds perfectly, except the only way I know how to get it to run is in Terminal.

Is there a way I can run the program in Xcode 4 or is Terminal it ?

like image 274
Chris Avatar asked May 04 '11 07:05

Chris


People also ask

Does Xcode use makefiles?

A MAKE file is an XCode script file that organize compilation of code. It is used to compile and link programs from multiple source code files. This help decide which parts of a large application are required to be recompiled when the application needs to be updated.

Can you compile in Xcode?

Great, now that Xcode is installed, you have two options for developing and running C programs on your Mac. The first option involves using Xcode as an editor only to write your source code, and using the "gcc" command within the Terminal window to compile your code.

What is makefile in CPP?

A makefile is a text file that contains instructions for how to compile and link (or build) a set of source code files. A program (often called a make program) reads the makefile and invokes a compiler, linker, and possibly other programs to make an executable file.


2 Answers

Yes, you can! Product -> Edit scheme Select "Run" from the left panel, select "Info" from top and specify "Executable" drop list Select next pane "Arguments" and add "Arguments Passed On Launch" (to "Executable" you select before)

like image 124
Artem Aminov Avatar answered Sep 28 '22 17:09

Artem Aminov


Yes, you need to create a Custom Executable, so that Xcode knows where your built executable resides and how to run it. In Xcode 3 it's Project -> New Custom Executable....

This will allow you to to run your executable and even do source level debugging if you have added the source code to the project. The only minor hassle is that you have to manually select which custom executable is "active" when you switch between e.g. debug and release builds.


Note re Xcode 4: I don't use Xcode 4 but looking at the online help the nearest equivalent to Xcode 3's "custom executable" seems to be:

Customize Executables in the Scheme Editor
To customize the environment in which a product is launched in Xcode 3, you click the executable in the Groups & Files list and then open the Info window. In Xcode 4, choose Edit Active Scheme from the Scheme pop-up and choose the product you want to run (Figure 3-10). Note that you can choose to display the running product at a higher UI resolution to simulate running at a different display resolution.

like image 26
Paul R Avatar answered Sep 28 '22 17:09

Paul R