Hi all,
I've bought the book "Objective-C Programming - The Big Nerd Ranch Guide" and I'm running through the beginning chapters which just regard C.
I'm doing this on my laptop running linux as I don't have a Mac (yet).
I'm having trouble with this code:
#import <stdio.h>
#include <readline/readline.h>
#include <readline/history.h>
int main(int argc, char * argv[]) {
printf("Who is cool? ");
const char *name = readline(NULL);
printf("%s is cool!\n\n", name);
return 0;
}
I'm compiling (attempting to) using this command:
gcc -lreadline -o Coolness main.c // "Coolness" being the name of the program in the book
I'm getting the following error when trying to compile:
main.c:1:2: warning: #import is a deprecated GCC extension [-Wdeprecated]
/tmp/ccjLJXtd.o: In function main': main.c:(.text+0x1d): undefined reference to
readline'
collect2: error: ld returned 1 exit status
I've been trying to look up a solution but have so far only managed to get as far as the compile command above, grabbing the readline includes and adding #include <readline.h> and <history.h> (though I'm not sure what history.h is for or if I need it).
Any assistance would be greatly appreciated.
Thanks