2016-04-25 1 views
3

Je pense que je dois installer la librairie editline (libedit?) Mais où puis-je l'obtenir pour OpenBSD? Le code compile très bien avec PC-BSD, mais avec OpenBSD je reçois cette erreurImpossible de compiler avec editline sur OpenBSD

implicit declaration of rl_bind_key 

Il est la bibliothèque editline qui est introuvable. J'ai essayé googling pour où le trouver pour OpenBSD, mais il n'a pas été trouvé. Pouvez-vous m'aider? Les en-têtes que j'utilise sont

#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 

Ceci est le code incriminé

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; 
} 

Si je lance locate editline il trouve et je changer le Makefile et obtenir une nouvelle erreur undefined reference to tgetnum cela selon google semble que je dois lier avec la bibliothèque ncurses. Maintenant, il compile. Le nouveau Makefile est:

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 
+1

montrent la commande de compilation (peut-être fait par 'make') –

+1

question connexe: http://stackoverflow.com/q/22886475/562459 –

Répondre

1

Vérifiez où editline/readline.h se trouvent (par exemple avec locate).

Si c'est dans /usr/local/include, vous devriez probablement ajouter cela à votre CFLAGS dans votre Makefile;

CFLAGS := $(CFLAGS) -I/usr/local/include -pedantic -std=c99 -Wall -O3 -g -DVERSION=\"$(GIT_VERSION)\" 
LDIRS = -L/usr/local/lib 
LIBS = -ledit 

SRCS= main.c errors.c util.c pipeline.c 
OBJS= $(SRCS:.c=.o) 

shell: $(OBJS) 
    $(CC) $(LDIRS) -o shell $(OBJS) $(LIBS) 
+0

Il est dans'/usr/local/include/ereadline/readline/readline.h' –