Dingo
Dingo

Reputation: 94

readline not working properly

When I run this code in Xcode, I get build failed. I got the chunk from The Big Nerd Ranch Guide to Obj-C. I had to modify it a little (added the libraries stdlib.h and readline/readline.h) It says the build failed, but there are no errors that I can see. This question may look like a duplicate, and in a way it is, but even after seeing their solutions and trying them for myself, I still get the error.

#include <stdio.h>
#include <readline/readline.h>
#include <stdlib.h>

int main(int argc, const char * argv[])
{
    printf("Who is cool? ");
    const char *name = readline(NULL);
    printf("%s is cool!\n\n", name);
    return 0;
}

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)

Upvotes: 0

Views: 724

Answers (1)

anon
anon

Reputation:

A similar problem is mentioned in this link. You have to link the libreadline.dylib file to your project in the build phase.

Upvotes: 1

Related Questions