I am using Cygwin, and am trying to write a game trainer. I would like to be able to have a user simply press a key to enable/disable features, and not have to press enter afterwards. It seems like getch() from the ncurses library should be able to do that. However, when I try to use getch(), I get the error "Use of undefined identifier 'getch'". The build output then also shows undefined references to ncwrap_stdscr and wgetch.
I have tried including curses.h instead of ncurses, but that gives the same error (which makes sense, as the ncurses header file appears to just be a symlink to curses.h anyway).
In theory, I would think that this code should build just fine:
#include <iostream>
#include <ncurses.h>
int main() {
int in = getch();
std::cout << in << std::endl;
}
This is the output from the build:
CMakeFiles/getchTest.dir/main.cpp.o: In function `main':
/cygdrive/c/Users/Sasschary/CLionProjects/getchTest/main.cpp:5: undefined reference to `ncwrap_stdscr'
/cygdrive/c/Users/Sasschary/CLionProjects/getchTest/main.cpp:5: undefined reference to `wgetch'
collect2: error: ld returned 1 exit status
make[3]: *** [CMakeFiles/getchTest.dir/build.make:84: getchTest.exe] Error 1
make[2]: *** [CMakeFiles/Makefile2:76: CMakeFiles/getchTest.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/getchTest.dir/rule] Error 2
make: *** [Makefile:118: getchTest] Error 2
Thanks in advance for your help!