Build error on challenge

getting the build error:

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

with code:

[code]#import <readline/readline.h>
#import <Foundation/Foundation.h>

int main(int argc, const char * argv[])
{

@autoreleasepool {
    NSLog(@"Who is cool? ");
    NSString *name = [NSString stringWithUTF8String:readline(NULL)];
    NSLog(@"%@ is cool!", name);
}
return 0;

}[/code]

not sure where to go…

On a new iMac 27", Mavericks, xcode 502

jack

Didn’t the book ask you to add to your project a framework or library that contains the definition of the readline () function?

duh!

Thanks for the slap upside the head! :smiley:

I can’t believe I forgot that in just a few chapters.

jack

Thanks for the help, I ran into this same problem. I knew it had to be something simple, since readline() used to work, but I had totally forgotten about this.

Sorry, but i thought that by typing #import <readline/readline.h> at the top of the project, he is already added the required library.
I have done the same but cannot get rid of the error:

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

Please help!!!

*** I’m using Xcode 4.4. If that’s the problem, is there an other way of reading strings from the command line?

I am sure the book has asked you to add a framework or library to your project, and most likely you forgot to do it.

#importing a file does not automatically add the associated frameworks or libraries to your project; remember, you are programming in Objective-C, not Java!

I think you can’t pass readline(NULL) as an argument. In the line:NSString * string =[NSString stringWithUTF8String:readline(NULL)]; you need to add a const char instead of readline thing. which you declare before so here is how it should look like:

[code] const char *xi = readline(NULL);

    NSString * string =[NSString stringWithUTF8String:xi];[/code]

Hope it helps: )

I found that using

//using #include or #import works #import <readline/readline.h>
Solves the problem