How can I build a makefile project with Xcode 5? - c++

I would like to use Xcode to debug a C++ program step by step. The project can be build using make. How can I build it using Xcode 5?

Here are the steps
1) create a new project using the following
a) go to OS X other
b) Create an empty project
2) create a blank file (under OS X other again) and call it Makefile
3) create a new target (file -> new -> target - call it whatever you want)
go to OS X target and select external build system
4) If you want a particular PATH variable you can Add a new user define setting (under
editor -> add Build Setting -> Add user defined setting
5) This should enable your target to be the makefile

Related

Compile and execute cpp in xcode, and add additional execution instructions, Such as iconv command

Sorry, I'm new to Xcode and not very familiar with it, I use Xcode (command line tool project with external build system) to compile cpp files and automatically execute cpp unix executable files. After the program is compiled (command+R), I set the settings as shown in the screenshot below to automatically execute. Is there any way for me to execute also add additional commands?
Such as iconv.
The following line is what I ultimately want to execute.
./myFile argument1 | iconv -f big5
But my Xcode looks like it's executing only
./myFile argument1
really thanks
On the same place where you setup the build scheme, you can also add a post-build script.
Go to the left of the panel, and expand Build
Select Post-actions
Near the bottom center, click on + -> New Run Script Action
Add script like you would run them in terminal
Note the current directory will not be where the project is built
You can use ${TARGET_BUILD_DIR} macro for the build directory
Note, you want to make sure to select your current project at the Provide build settings from so it can import the correct path macros like TARGET_BUILD_DIR
A screenshot of adding a post-build script:
*Older versions of Xcode might have different GUI, but the idea should be about the same.
Sidenote, ⌘R is really for running the program within Xcode, consider using ⌘B.

How to include functions from other C++ files in a new program (for Mac OSX applications)

How can I import functions from one Mac program I already have into a new program. Both are in the same workspace, but I want too access functions from the older one in the new one. I tried just copying and pasting the functions over (I know, not the greatest way to do it), but got mach-o linker errors that I couldn't fix.
Here is permanent solution.Generally overwriting project may cause this prolems.Try this method.
-UPDATE - Clang error - Mach-O Linker error
In some case error log window displaying .xctest error, to fix it
-> Select your project
-> Beside this(just before General tab) select your projectTest file from dropdown
-> There is one option (like ProjNameTests)
-> In Host Application, select your project from dropdown only if it show custom
DONE!

Cocoapods Unable to find a target

I am trying to install some libraries in a project using cocoapods on my vmbox. The current Podfile is in the same directory as my .xcodeproj and the contents of my Podfile is:
platform :ios, '7.0'
pod 'Mantle'
pod 'LBBlurredImage'
pod 'TSMessages'
pod 'ReactiveCocoa'
When trying to run:
pod install
from the command line I get the error
[!] Unable to find a target
Similar question here:
How do I select a project in my Podfile? I'm getting the error: Unable to find the Xcode project for the target 'Pods'
For me I edited using the pico editor as instructed in the tutorial, and it worked.
The problem appears because your "Target build" is empty in your Xcode (Project file -> Targets). In Xcode 6.0+ when you create an "Empty" project (File -> New Project -> Others), it creates an totally empty project, not like in the previous versions. If you want to have an empty project like in Xcode 5, you need to create an "Single View Application" and make some changes like described here: How to create an Empty Application in Xcode 6 without Storyboard

Adding "libusb.h" search path to Xcode 5 (OS X v10.9 (Mavericks))

I am trying to get the Kinect library "libfreenect" to work on OS X v10.9 (Mavericks). It always ends in "device not found". So I thought I could test libusb with Xcode to see what USB devices are recognised.
I am using sample code from Introduction To Using LibUSB-1.0
Xcode project settings are:
OS X -> Application -> Command Line Tool
C++
When trying to compile, Xcode complains:
/.../libusb-Test/libusb-Test/main.cpp:2:10: 'libusb.h' file not found
I tried several things to fix the issue:
Adding "/opt/local/include" to: Preferences -> Locations
Adding "/opt/local/include/libusb-1.0" to: Preferences -> Locations
Adding "/opt/local/include/libusb-1.0" to: Build Settings -> Library Search Path
IMAGE: Xcode, Build Settings
The only thing that seems to work is:
#include </opt/local/include/libusb-1.0/libusb.h>
But that doesn't seem to be the proper way of doing it.
I recommend you verify that the "Always Search User Paths" Build Setting is set to YES. Then you might add a User Header Search Path that includes the directory holding your reference.

kdevelop no valid executable specified

I've just installed kdevelop 4.1 , then created a normal hello world , build is ok but when i press execute it gives me (no valid executable specified) any idea ?
Meh, the launch configuration - our biggest usability problem...
Go to Run -> Configure Launches
select your project to the left
hit the "+" button
to the right, select your project target
optionally add a build dependency (again, select e.g. your target).
that should be it.
/me really wants to rewrite this dialog...
After following the steps provided by milianw. In case it doesn't work, follow this steps:
Go to Run >> Current Launch Configuration
choose the current file name you are trying to compile.