2

I have just started learning Objective-C and I am stuck on a very simple issue. I have written a small program and trying to compile it through Mac terminal by using following command:

clang -framework Foundation main.m -o prog

It was working fine until I wrote the following code in main.m

Calculator *calculator = [[Calculator alloc]initWithExpression:expressionArray];

It has started giving me following error:

Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_Calculator", referenced from:
      objc-class-ref in main-a39d3a.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

How to tell compiler to import calculator.h file although I have included the following line in main.m:

#import "Calculator.h"
2
  • Do you also have a 'calculator.m' file? Commented Mar 26, 2016 at 1:58
  • 1
    You need to include Calculator.m on the compile line so it gets linked with main.m. Commented Mar 26, 2016 at 2:02

1 Answer 1

6

If you have a file 'Calculator.m' in your sources, your compile command must look like

clang -framework Foundation Calculator.m main.m -o prog
Sign up to request clarification or add additional context in comments.

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.