1

I'm trying to use the readline library in my c++ project using netbeans, so I've installed libreadline6-dev and add it to my project Properties -> Linker -> Additional Library directories -> and add (usr/include/readline).

But while compiling I get this error : undefined reference to 'readline'.

I found that I need to add also -lreadline to somewhere, but I have no idea where to put it.

Any ideas.

Thanks

Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
Wassim AZIRAR
  • 10,823
  • 38
  • 121
  • 174
  • 1
    (I removed the java tag, since this has nothing to do with Java, apart from that Netbeans is written in Java.) – Paŭlo Ebermann Feb 08 '11 at 00:26
  • I did that just to have more viewers ;) – Wassim AZIRAR Feb 08 '11 at 00:42
  • 2
    That is inconsiderate, to say the least. People who follow the [java] and [c#] tags do so because the are interested in questions about Java and C#. You might have gotten a few extra people to view this question, but those people are almost certainly not the people who can actually answer it: the people who can answer it already follow the [c++] tag. – James McNellis Feb 08 '11 at 01:46

1 Answers1

4

You are on the good way, the problem you got is about the linker.

You have to specify the library(readline) here:

Project properties -> Build -> Linker -> Libraries.

and you also need to specify the path of the library:

Properties -> Linker -> Additional Library directories

But, like nos said, it is not the include directory.The include directory is the headers of the library(.h).

The linker needs a file with the extension .a on UNIX, it should be under a lib directory (ex: /usr/lib depends on where the library is installed).

If it is not working be sure that the file [library_directory]/libreadline.a exists

You also need to link ncurses with your project because readline uses it.

Maxence SCHMITT
  • 609
  • 4
  • 12