GCC的/ usr / bin中/ LD:错误:无法找到-lncurses [英] gcc /usr/bin/ld: error: cannot find -lncurses
问题描述
我运行Ubuntu 12.04和我目前正在对涉及C,OpenGL的,一个茶壶和输入法的一个项目。
当我决定方向键输入的问题开始。我检查关键看codeS的方向键,但所有的箭头返回0。我抬头一看怎么得到这个工作,我发现CONIO.H。不幸的是,这是一种古老的DOS头,是不是可用于Linux。然后我发现了一个名为ncurses的替代品。
安装必要的库,通过密切关注构建指令后,我在main.c中包含(#include)来源curses.h里。当我第一次尝试使用gcc来编译,我得到了以下错误:
main.o中:main.c中:功能_key:错误:未定义引用stdscr上
main.o中:main.c中:功能_key:错误:未定义引用'wgetch
main.o中:main.c中:功能_key:错误:未定义引用stdscr上
main.o中:main.c中:功能_key:错误:未定义引用'wgetch
我找到了解决加入-lncurses的makefile文件,像这样:
来源= main.c中主:main.o中
gcc的-lm -lGL -lGLU -lglut -lncurses main.o中主要-omain.o中:main.c中
gcc的-lm -lGL -lGLU -lglut -c main.c中
但我迎接另一个错误:
的/ usr / bin中/ LD:错误:无法找到-lncurses
以及previous错误。
我花了最后2天都搜索了Ubuntu论坛和计算器。任何帮助将是AP preciated。
P.S。我不知道这是很重要的,但是当我尝试运行/ usr / bin中/ LD我得到这个错误:
LD:致命错误:没有输入文件
对于同样的问题,我没有任何人:我是缺少32位库;我编写这是缺少lib32ncurses5-dev软件包在64位服务器上的32位。
在Ubuntu的,我只是跑了:
命令和apt-get安装lib32ncurses5-dev的
I am running Ubuntu 12.04 and I'm currently working on a project involving C, OpenGL, a teapot and input methods.
The problem started when I decided to have arrow keys as input. I checked to see the key codes for arrow keys but all of the arrows return 0. I looked up how to get this to work and I found conio.h. Unfortunately, it is an old DOS header that is not available for Linux. Then I found a substitute called ncurses.
After installing the necessary libraries, by following the build instructions closely, I #included curses.h in my main.c source. When I first tried to compile using gcc, I got the following errors:
main.o:main.c:function _Key: error: undefined reference to 'stdscr'
main.o:main.c:function _Key: error: undefined reference to 'wgetch'
main.o:main.c:function _Key: error: undefined reference to 'stdscr'
main.o:main.c:function _Key: error: undefined reference to 'wgetch'
I found a fix by adding -lncurses to the makefile like so:
SOURCES=main.c
main: main.o
gcc -lm -lGL -lGLU -lglut -lncurses main.o -o main
main.o: main.c
gcc -lm -lGL -lGLU -lglut -c main.c
But I was greeted by another error:
/usr/bin/ld: error: cannot find -lncurses
As well as the previous errors.
I have spent the last 2 days searching both the Ubuntu forums and StackOverFlow. Any help would be appreciated.
P.S. I don't know if this is important but when I try to run /usr/bin/ld I get this error:
ld: fatal error: no input files
For anyone with the same problem I had: I was missing the 32 bit libraries; I was compiling 32 bit on a 64 bit server which was missing the lib32ncurses5-dev package.
On Ubuntu I simply ran:
sudo apt-get install lib32ncurses5-dev
这篇关于GCC的/ usr / bin中/ LD:错误:无法找到-lncurses的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!