Undefined reference to `stdscr#39; while using ncurses(使用 ncurses 时对 `stdscr 的未定义引用)
问题描述
我正在尝试在 Ubuntu 11.10 中编译我的代码并出现这些错误等等.到目前为止,通过谷歌搜索,我认为这是一个链接错误.具体来说,有一些建议可以确保您拥有正确的标题并链接 -lncurses 库.我已经这样做了.我仍然收到此错误.我还读到可能我应该安装 libncurses,但我已经安装了它.
I am trying to compile my code in Ubuntu 11.10 and getting these errors and more.So far by googling it I think it is a linking error. Specifically, there have been suggestions to make sure you have the right headers and link the -lncurses library. I have already done that. I'm still getting this error. I also read that may be i should install the libncurses, but I already have it installed.
My MakeFile:
CPP = g++
CPPFLAGS = -c -Wall -g
LINK = g++
LDFLAGS_LINUX = -lpthread -lncurses
LDFLAGS = $(LDFLAGS_LINUX)
RM = rm
.SUFFIXES:
.SUFFIXES: .o .cpp
.cpp.o:
$(CPP) $(CPPFLAGS) $*.cpp -o $(SRC_DIR)$*.o
all: skygrid
skygrid: skygrid.o commServer.o pose.o robot.o
$(LINK) $(LDFLAGS) -o $@ $^
clean:
$(RM) -rf *.o skygrid
skygrid.o: skygrid.cpp definitions.h commServer.h pose.h robot.h
commServer.o: commServer.cpp commServer.h
pose.o: pose.cpp pose.h
robot.o: robot.cpp robot.h pose.h
我的错误:
/home/fari/Desktop/FarahSkygrid/skygrid/src/skygrid.cpp:1094: undefined reference to `stdscr'
/home/fari/Desktop/FarahSkygrid/skygrid/src/skygrid.cpp:1094: undefined reference to `stdscr'
/home/fari/Desktop/FarahSkygrid/skygrid/src/skygrid.cpp:1094: undefined reference to `stdscr'
/home/fari/Desktop/FarahSkygrid/skygrid/src/skygrid.cpp:1094: undefined reference to `stdscr'
/home/fari/Desktop/FarahSkygrid/skygrid/src/skygrid.cpp:1104: undefined reference to `werase'
/home/fari/Desktop/FarahSkygrid/skygrid/src/skygrid.cpp:1106: undefined reference to `wprintw'
/home/fari/Desktop/FarahSkygrid/skygrid/src/skygrid.cpp:1107: undefined reference to `wprintw'
/home/fari/Desktop/FarahSkygrid/skygrid/src/skygrid.cpp:1109: undefined reference to `wprintw'
/home/fari/Desktop/FarahSkygrid/skygrid/src/skygrid.cpp:1111: undefined reference to `stdscr'
/home/fari/Desktop/FarahSkygrid/skygrid/src/skygrid.cpp:1111: undefined reference to `wgetch'
/home/fari/Desktop/FarahSkygrid/skygrid/src/skygrid.cpp:1116: undefined reference to `wtouchln'
推荐答案
我在 Centos 6.2 上的 ncurses 程序中遇到了这个问题.事实证明,ncurses 有时被分成两个库,ncurses
和 tinfo
.就我而言,stdscr
存在于 libtinfo
中,而不存在于 libncurses 中,因此将 -ltinfo
添加到链接行,在 -lncurses<之后/code>,解决问题.
I was having this problem with an ncurses program on Centos 6.2. It turns out that ncurses is sometimes split into two libraries, ncurses
and tinfo
. In my case, stdscr
exists in libtinfo
, not in libncurses, so adding -ltinfo
to the link line, after -lncurses
, solved the problem.
这篇关于使用 ncurses 时对 `stdscr' 的未定义引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 ncurses 时对 `stdscr' 的未定义引用
基础教程推荐
- 在 C++ 中循环遍历所有 Lua 全局变量 2021-01-01
- 使用从字符串中提取的参数调用函数 2022-01-01
- 如何使图像调整大小以在 Qt 中缩放? 2021-01-01
- 为 C/C++ 中的项目的 makefile 生成依赖项 2022-01-01
- 为什么语句不能出现在命名空间范围内? 2021-01-01
- Windows Media Foundation 录制音频 2021-01-01
- 管理共享内存应该分配多少内存?(助推) 2022-12-07
- 从 std::cin 读取密码 2021-01-01
- 如何“在 Finder 中显示"或“在资源管理器中显 2021-01-01
- 如何在不破坏 vtbl 的情况下做相当于 memset(this, ...) 的操作? 2022-01-01