即使链接curses,G ++也找不到对raw()或cbreak()的引用 [英] G++ can't find references to raw() or cbreak(), even when linking curses

查看:152
本文介绍了即使链接curses,G ++也找不到对raw()或cbreak()的引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即使我以前使用过curses.h,也无法完成一些绝对的基础工作.我敢肯定,这是丢失一些小东西的经典案例,但是我已经不知所措了.

I'm having trouble getting some absolute basic work with curses.h done, even though I've worked with it before. I'm sure it's a classic case of missing something small, but I'm at my wit's end.

G ++绝对不会识别函数raw()或cbreak(),即使curses.h包含在我的.cpp和头文件中,在使用(最小版本):

G++ absolutely won't recognize the functions raw() or cbreak(), even though curses.h is included in my .cpp and header file, and linked to when compiling with (minimal version):

g++ debugC.cpp -lcurses

相关代码为:

#include <curses.h>
#include "debugC.h"
#include "machine.h"

using namespace std;

debugC::debugC(machine *BFM){
    localMachine = BFM;
}

//entry into debugger
void debugC::start(){
    void * v = NULL;
    initscr();
    raw();
    noecho();
}

g ++返回的错误:

The errors returned by g++:

/usr/bin/ld: /tmp/cci6mA0L.o: undefined reference to symbol 'raw'
/usr/lib/libtinfo.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

为了清楚起见,我将其简化为功能最少的代码.它无需调用raw()就可以编译.

I've stripped this down to minimal functioning code for clarity. It compiles without the call to raw().

curses.h已明确包含在内,并且在编译时已链接了它.它怎么会不理解对某些curses函数的引用,而对另一些curses函数的引用呢?

curses.h is clearly included, and I've linked against it when compiling. How could it not understand references to some curses functions, and not others?

我已经向SO和Google寻求帮助,但似乎找不到解决方案,我非常感谢任何可能的见解.谢谢.

I've scoured SO and Google for help but I can't seem to find a solution, I'd really appreciate any possible insight. Thanks.

推荐答案

某些系统将ncurses配置为两个库: ncurses (或 ncursesw ),这是高级的库和 tinfo (或 tinfow )(低层库). raw 是一个低级功能.

Some systems configure ncurses as two libraries: ncurses (or ncursesw) which is the high-level library, and tinfo (or tinfow) which is the low-level library. raw is a low-level feature.

大多数系统提供程序包/配置脚本(例如, pkg-config的数据文件),并且--libs选项列出以这种方式构建的两个库:

Most systems provide the package/configuration scripts (e.g., ncursesw6-config or the data files for pkg-config), and the --libs option lists both libraries when it is built in this way:

$ ncursesw6-config --libs
-lncursesw6 -ltinfow6

$ pkg-config --libs ncursesw6
-lncursesw6 -ltinfow6

例如,假设正确安装了pkg-config,则可以执行以下操作:

For example, assuming a correctly installed pkg-config, you could do something like:

g++ debugC.cpp $(pkg-config --libs ncurses)

在某些配置中(例如,使用 rpath 功能),从属库名称存储在共享库中,因此所需要做的就是参考顶级库以获取两个都. Debian(以及诸如Ubuntu之类的派生系统)不使用 rpath ,而是将ncurses配置为两个库.

In some configurations (using the rpath feature for instance), the dependent library names are stored in the shared library, so that all one needs to do is refer to the top-level library to get both. Debian (and derived systems such as Ubuntu) don't use rpath, while also configuring ncurses as two libraries.

通过以下方式提供了两种配置方法(但取决于打包程序...):

Two methods of configuration are provided (but depends on the packager...), by the way:

  • ncurses*-config脚本早于pkg-config,并且可以工作(尽管有些人对交叉编译器工具的命名约定感到困惑),而
  • pkg-config在标准化方面存在问题(单平台开发人员未注意到).
  • ncurses*-config script predates pkg-config, and works (though some are confused by the naming convention for cross-compiler tools), while
  • pkg-config has problems with standardization (not noticed by single-platform developers).

这篇关于即使链接curses,G ++也找不到对raw()或cbreak()的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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