2016-02-14 94 views
0

我得到的錯誤:未定義的引用「的ReadLine」 - ç

undefined reference to `readline' 

這裏是我的makefile:

all: stest stestdebug 

stest: stest.o struct.o 
    gcc -g stest.o struct.o -lreadline -lncurses -o stest 

stest.o: stest.c struct.h 
    gcc -g -c stest.c 

stestdebug: stestdebug.o struct.o 
    gcc -g stestdebug.o struct.o -o stestdebug 

stestdebug.o: stest.c struct.h 
    gcc -g -c stest.c -o stestdebug.o 

struct.o: struct.c struct.h 
    gcc -g -c -DDEBUG struct.c 

clean: 
    rm -f *.o stest stestdebug 

docs: 
    doxygen 
    chmod a+r html/* 
    cp -p html/* ~/public_html/cs2303assig4 

我已經進口的所有一行readline必要的庫,但我仍然得到這個錯誤。

這裏是我把它叫做代碼:你是不是鏈接到他們在你的主可執行

#include <stdio.h> 
#include <stdlib.h> 
#include <string.h> 
#include <readline/readline.h> 
#include <readline/history.h> 
#include "struct.h" 

void requestInput() { 
    printf("Please fill out all prompts to create a new emplyoee.\n"); 
    char *name = readline("Name:"); 
} 
+5

您對stest目標有-lreadline,但對stestdebug目標沒有。 –

+3

這是一個[重複](https://stackoverflow.com/questions/14773420/undefined-reference-to-readline)或一個錯字;可能都是。 – 5gon12eder

回答

0

將你的庫放入一個變量中,並將它們用於測試目標和正常目標。

查看LDFLAGS。