I'm t开发者_运维知识库rying 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
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.
精彩评论