I'm trying to build a command-line application in Xcode for OS X 10.9 which contains a .cpp source file, which uses a function externally defined in a .asm assembly file. The C++ code:
#include <iostream>
using namespace std;
extern "C" void NOTHING();
int main(){
NOTHING();
return 0;
}
The following is the assembly function:
global NOTHING
section .text
NOTHING:
mov eax, 0
ret
It's a program that does nothing but temporarily move the value zero into the EAX register. I made sure to choose NASM assembly when creating the .asm source file. When I hit the 'play' button to build the executable, Xcode simply states build failed, without specifying a reason.
I could revert back to doing it all in the command line, as I would on Linux. However, if possible, I'd prefer to start using Xcode, as it combines many tools, e.g. Git, into a single application for development.
EDIT: After the answer, I have decided to abandon Xcode; the command line is just much simpler. Based on the answer, I have written the following 'makefile' for future users visiting the question:
test: main.cpp asm.o
g++ -stdlib=libstdc++ main.cpp asm.o -o test
asm.o: asm.asm
nasm -f macho64 asm.asm -o asm.o
which assumes the assembly file is 'asm.asm', the C++ 'main.cpp', and the executable created is named 'test.' As in the answer, make sure functions in the .asm file begin with an underscore.