3

I am a beginning programming student.

Here I have written a simple "sum of two numbers" program in Xcode using C++.

//preprocessor directive
#include <stdio.h>

//local declarations

int main (void)
{
//declare variables
int n1, n2, sum;

//input prompts
printf("This program finds the sum of two numbers. Enter your first number.\n");
scanf("%d" , &n1);

printf("Enter another number.\n");
scanf("%d" , &n2);

//process
sum=n1+n2;

//output
printf("The sum is %d." , sum);

return 0;

}

As far as I can tell, my syntax is accurate, however, when I try to build the program, I get this error code:

"Apple Mach-O Linker (Id) Error. Linker command failed with exit code 1 (use -v to see invocation)"

I have been unable to solve this by reading other Q's and A's.

Any proposed solution? It would be greatly appreciated!!

1
  • That can't be the only error, there must be more before it. Commented Jan 24, 2014 at 16:16

2 Answers 2

1

Your error is incomplete. You need to use -v to see invocation (as suggested) or you need to check your log for more details as the error 'Linker command failed with exit code 1' is usually followed by the more detailed error.

So to find more details, in Xcode click on the error under Buildtime and choose Reveal in log. This should give you extra hint. Without any specific error, it's difficult to know what's the problem.

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

Comments

0

This error is normally displayed if you have other errors in your source code. If you copy pasted the code directly, there is an x before the opening brace in main.

3 Comments

okay. thanks. the "x" before opening brace was just a copying error, not in the code I tried to compile.
Then there must be some other error - what is showed in Issue Navigator?
The Issue Navigator says "one issue." - "Apple Mach-O Linker (Id) Error - Linker command failed with exit code 1 (use -v to see invocation)"

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.