I assume that the library and the header files has been installed. Otherwise you would get a compiler error about missing include files.
You must pass the libraries after the source files when compiling and linking with a single line:
gcc -Wall source-file.cpp -lreadline -o program-name
The common gcc option sequence is then:
- Compiler options like optimising and include pathes
- Source files
- Linker options like libraries and library pathes
- Output
Or split compiling and linking into two commands:
gcc -Wall -c source-file.cpp
gcc source-file.o -lreadline -o program-name