"/usr/bin/gmake" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
gmake[1]: Entering directory `/home/josh/Projects/Testing grounds/kbhit'
"/usr/bin/gmake" -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux-x86/kbhit
gmake[2]: Entering directory `/home/josh/Projects/Testing grounds/kbhit'
mkdir -p build/Debug/GNU-Linux-x86
rm -f build/Debug/GNU-Linux-x86/main.o.d
g++ -c -g -Iusr/include/ -MMD -MP -MF build/Debug/GNU-Linux-x86/main.o.d -o build/Debug/GNU-Linux-x86/main.o main.cpp
mkdir -p dist/Debug/GNU-Linux-x86
g++ -o dist/Debug/GNU-Linux-x86/kbhit build/Debug/GNU-Linux-x86/main.o -L/usr/include/ncurses -L/usr/include/ncurses6 -L/usr/include/ncursesw -lncurses.h
/usr/lib64/gcc/x86_64-suse-linux/4.6/../../../../x86_64-suse-linux/bin/ld: cannot find -lncurses.h
collect2: ld returned 1 exit status
gmake[2]: *** [dist/Debug/GNU-Linux-x86/kbhit] Error 1
gmake[2]: Leaving directory `/home/josh/Projects/Testing grounds/kbhit'
gmake[1]: *** [.build-conf] Error 2
gmake[1]: Leaving directory `/home/josh/Projects/Testing grounds/kbhit'
gmake: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 477ms)它似乎找不到'' lcurses '‘,但我从来没有为它定义过查找lcurses。我实际上添加了要链接的ncurse库。
我已经导航到/usr/include/ncurses,实际上那里应该有文件。
我不完全知道整个编译过程中发生了什么,这有点超出了我的能力范围。我只知道我被告知要链接我需要的库。ncurses.h就在那里,这就是我的代码。
#include <iostream>
#include <ncurses/ncurses.h>
using namespace std;
bool kbhit()
{
int ch = getch();
if(ch != ERR)
{
ungetch(ch);
return true;
}
return false;
}
int main() {
while(!kbhit())
{
cout << "no input";
}
cout << "Mummy, it's over.";
return 0;
}欢迎任何帮助;我迷路了。
发布于 2012-05-13 21:08:13
这不是您的c++代码的问题,而是您的构建环境的问题,您正在使用netbeans IDE吗?
据我所知,这段代码根本不需要ncruses,而链接指令NetBeans?已经为您设置了指向ncruses.h文件的指针,其中应该是类似于"-Wl,-lncurses“或仅为"-lncurses”的内容。因此,一个猜测是,在netbeans中的某个地方,您应该指出库名称,您已经编写了ncruses.h,而不仅仅是ncruses(我想,不确定)
尝试询问pkg-config,ncurses的参数应该在您的机器上:"pkg-config --libs ncurses“和"pkg-config --cflag ncurses”
https://stackoverflow.com/questions/10571461
复制相似问题