在学习用C语言写个简单的Lisp语言
源代码如下:
#include <stdio.h>
#include <stdlib.h>
#include <editline/readline.h>
#include <editline/history.h>
int main(int argc, char *argv[]) {
puts("Lispy Version 0.1");
puts("Press Ctrl+c to Exit\n");
while(1){
char* input = readline("lispy> ");
add_history(input);
printf("no you're a %s\n",input);
free(input);
}
return 0;
}
bug1:fatal error: 'editline/history.h' file not found
解决:
- 移除
#include <editline/history.h>
出现:
Undefined symbols for architecture x86_64:
"_add_history", referenced from:
_main in Untitled 4-73916f.o
"_readline", referenced from:
_main in Untitled 4-73916f.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
解决:
增加编译参数:
-std=c99 -Wall -ledit
-Wall 是将产生尽可能多的警告信息 ,-ledit是链接edit库(猜测)
记录一个搜索问题,当我谷歌 gcc -Wall的时候没有搜到想要的信息,想起几天前看的搜索技巧,可能把-后的参数去除了,于是再次搜索"gcc -Wall",加了引号,搜到了结果,注:mac是用cc编译的,但是cc -Wall没有搜索想要的信息,于是换成了gcc
网友评论