私はもともとWindowsのためだけだったいくつかのヘッダーを使用しようとしていましたが、悪いですが、curses.hを使って必要なものを再現しました。しかし、私はまだまったく同じ種類のエラーを受けています。ncurses&curses - コンパイラが定義していない参照
"/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 -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
build/Debug/GNU-Linux-x86/main.o: In function `kbhit()':
/home/josh/Projects/Testing grounds/kbhit/main.cpp:20: undefined reference to `stdscr'
/home/josh/Projects/Testing grounds/kbhit/main.cpp:20: undefined reference to `wgetch'
/home/josh/Projects/Testing grounds/kbhit/main.cpp:23: undefined reference to `ungetch'
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
私は、コードが期待通りに機能するかどうかは100%確信していません。私はちょうどそれをテストするためにこれをコンパイルしようとしています。 curses.hのドキュメントによると、getchは、キーがキューに入れられていない場合、値ERRを返すと想定されています。私はここに必要なものが何であるかは分かりませんが、私が必要とするのは定義が入っていたヘッダーを含めるだけだと思っていました。それだけでは不十分です。コンパイルしようとしている短いテストです。
#include <cstdlib>
#include <iostream>
#include <curses.h>
#include <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;
}
どのように私は、NetBeansでそれを行うに行くでしょうか? –
netbeansがあなたのためにあなたのmakefileを管理している場合、リンカに渡されたライブラリのリストに 'ncurses'を明示的に追加する方法が必要です。あなたはドキュメントを試しましたか? –
私はどこを見て、何を探したらいいのかわかりません。限り、ファイルとコンパイラのオプションとたくさん作る、私は完全な初心者です。私はたいてい、ロジックをコードする方法しか知りません。ライブラリ/ヘッダーをよく使用していません。 –