我是C語言的新手,每當我用命令cc prompt.c
編譯我的C代碼時都會收到此錯誤。我得到這個錯誤:修改錯誤
Undefined symbols for architecture x86_64:
"_add_history", referenced from:
_main in prompt-66f61f.o
"_readline", referenced from:
_main in prompt-66f61f.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
這裏是我的代碼:
#include <stdio.h>
#include <stdlib.h>
#include <editline/readline.h>
int main(int argc, char** argv) {
/* Print Version and Exit Information */
puts("Lispy Version 0.0.0.0.1");
puts("Press Ctrl+c to Exit\n");
/* In a never ending loop */
while (1) {
/* Output our prompt and get input */
char* input = readline("lispy> ");
/* Add input to history */
add_history(input);
/* Echo input back to user */
printf("No you're a %s\n", input);
/* Free retrieved input */
free(input);
}
return 0;
}
我寫在MacBook Air上這個程序運行OSX 10.10.3,有沒有什麼幫助。
我剛剛開始學習C語言,所以不要評論我這個問題是否真的很簡單,當我搜索它時沒有結果。
任何幫助將不勝感激。謝謝!
你在編制呢? – cehnehdeh