我認爲我必須安裝editline(libedit?)庫,但我可以在哪裏獲得OpenBSD?該代碼與PC-BSD編譯良好,但與OpenBSD,我得到這個錯誤無法在OpenBSD上使用editline進行編譯
implicit declaration of rl_bind_key
這是編輯線庫沒有找到。我試着在Google OpenBSD的哪裏找到它,但沒有找到它。你可以幫我嗎?我使用的標題是
#define _XOPEN_SOURCE 500
#include <sys/stat.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/wait.h>
#include "openshell.h"
#include "errors.h"
#include <errno.h>
#include <locale.h>
#include <editline/readline.h>
的Makefile
CC = gcc
GIT_VERSION := $(shell git describe --abbrev=4 --dirty --always --tags)
CFLAGS := $(CFLAGS) -pedantic -std=c99 -Wall -O3 -ledit -g -DVERSION=\"$(GIT_VERSION)\"
shell: main.o
$(CC) -o shell main.o errors.c util.c pipeline.c -ledit
main.o: main.c errors.c util.c
.PHONY: clean
clean:
rm -f *.o
這是有問題的代碼
int exec_program(const char *name) {
FILE *fp;
int r = 0;
char *input, shell_prompt[100];
if (sourceCount >= MAX_SOURCE) {
fprintf(stderr, "Too many source files\n");
return 1;
}
fp = stdin;
if (name) {
fp = fopen(name, "r");
if (fp == NULL) {
perror(name);
return 1;
}
}
sourcefiles[sourceCount++] = fp;
setlocale(LC_CTYPE, "");
/*Configure readline to auto-complete paths when the tab key is hit.*/
rl_bind_key('\t', rl_complete);
stifle_history(7);
for (; ;) {
/* Create prompt string from user name and current working directory.*/
snprintf(shell_prompt, sizeof(shell_prompt), "%s:%s $ ", getenv("USER"), getcwd(NULL, 1024));
// Display prompt and read input (NB: input must be freed after use)...
input = readline(shell_prompt);
// Check for EOF.
if (!input)
break;
add_history(input);
r = command(input);
free(input);
}
return r;
}
如果我運行locate editline
然後查找和更改Makefile文件,並得到一個新的錯誤undefined reference to tgetnum
根據谷歌似乎我必須鏈接ncurses
圖書館。現在編譯。新Makefile
是:
CC = gcc
GIT_VERSION := $(shell git describe --abbrev=4 --dirty --always --tags)
CFLAGS := $(CFLAGS) -L/usr/local/include/ -L/usr/include -pedantic -std=c99 -Wall -O3 -g -DVERSION=\"$(GIT_VERSION)\" -ledit -lncurses
LDIRS = -L/usr/local/lib -L/usr/lib
LIBS = -ledit lncurses -lcurses
shell: main.o
$(CC) -o shell main.o errors.c util.c pipeline.c -ledit -lncurses -lcurses
main.o: main.c errors.c util.c
.PHONY: clean
clean:
rm -f *.o
顯示(可能如'make'完成)編譯命令 –
相關問題:http://stackoverflow.com/q/22886475/562459 –