未定义对"readline"的引用 [英] undefined reference to 'readline'

查看:457
本文介绍了未定义对"readline"的引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用netbeans在我的c++项目中使用readline库,所以我已经安装了libreadline6-dev并将其添加到我的项目中Properties-> Linker-> Additional Library directory->并添加(usr/include/readline).

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).

但是在编译时出现此错误:undefined reference to 'readline'.

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

我发现我还需要在某处添加-lreadline,但我不知道将其放置在何处.

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

任何想法.

谢谢

推荐答案

您处于良好状态,遇到的问题与链接程序有关.

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

您必须在此处指定库(readline)

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

但是,就像nos所说的那样,它不是包含目录.包含目录是库(.h)的头文件.

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

在UNIX上,链接器需要一个扩展名为.a的文件,该文件应位于lib目录下(例如:/usr/lib取决于库的安装位置).

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).

如果它不起作用,请确保文件[library_directory] ​​/libreadline.a存在

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

您还需要将ncurses链接到您的项目,因为readline会使用它.

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

这篇关于未定义对"readline"的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆