Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

first objective c program... getting the following error in command line...

clang: warning: argument unused during compilation: '-fobjc'
ld: warning: directory not found for option '-Foundation'
ld: framework not found -Foundation
clang: error: linker command failed with exit code 1 (use -v to see invocation)


Initially i realized that clang was missing. So after a google search I installed "command line tools" from xcode preference. Now I'm getting this error. Can someone tell me what it means?


I'm following the example in stephen kochan's programmin guide and using the following command to compile from command line...


Neeravs-MacBook-Pro:Stepen Kochan neeravkothari$ clang -fobjc -framework -Foundation main.m -o prog1



Thanks for your time going through this...


Neerav

MacBook Pro, OS X Mountain Lion (10.8.2), 13 inch, 2.4 Ghz, Mid 2010

Posted on Apr 11, 2013 10:11 PM

Reply
Question marked as Best reply

Posted on Apr 11, 2013 10:32 PM

DONE!


as per mentioned in the tutoria, upon reading it carefully, I simply deleted "-framework Foundation" and compiled it again. It worked.


i was also not adding -arc affter -fobjc


Thanks

8 replies

Apr 11, 2013 10:40 PM in response to AceNeerav

The message says that the compiler can not find the Foundation framework. You may know that Foundation is the the most important framework, which no Object-C code can execute without it.


I am not sure why this has happened, as I have never seen such error. Foundation is the basis of Cocoa and no doubt that exists on your system. But why your compiler can not find it?


I have not worked with Clang. But there must be some settings for the compiler in use, to determine the path of the Cocoa libraries and frameworks.


Help this helps you


Mani Ghasemnia Hamedani

Apr 12, 2013 7:53 AM in response to AceNeerav

If the book you are using is Programming in Objective-C by Kochan be aware that the newest edition of the book is the 5th and that there have been changes to Objective-C on the Mac since the earlier editions.


Specifically garbage collection and memory management as well as instance variable declarations.


The command line compile should be


clang -fobjc-arc main.m -o prog


But as etresoft wrote just dive into Xcode you're going to need to learn it at some point. Once you get use to it you'll find it is a great development environment



good luck

Apr 12, 2013 11:33 AM in response to AceNeerav

That's fine if you are learning the basics of C. Anything involving Objective-C is going to need a whole lot of extra stuff that isn't worth doing yourself on the command line. You can spend years of your life on a rabbit hole of useless knowledge, but other people who are just getting started need to know a more efficient path to understanding and productivity.

first objective c program... getting the following error in command line...

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.