0

The error I'm getting:

undefined reference to `readline'

Here is my 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

I've already imported all the necessary libraries for readline but am still getting this error.

Here is the code where I call it:

#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:");
}
5gon12eder
  • 24,280
  • 5
  • 45
  • 92

1 Answers1

0

You are not linking to them in your main executable.

Put your libraries in a variable, and use them both in your test target and the normal target.

Have a look into LDFLAGS.