I'm trying to familiarize myself with ncurses. When I compile this code on my IDE (cLion), it gives me the error:
"Error opening terminal: unknown"
I'm using Mac OSX.
If I compile using the terminal with: "g++ -lncurses main.cpp -o hello"
It compiles and runs successfully. But I'd like to figure out how to compile and run it on cLion. I've checked around every on this forum and haven't been able to fix the issue. I've modified the CMakeLists.txt file various ways and none worked.
Where is the issue?
main.cpp
#include <ncurses.h>
using namespace std;
int main() {
initscr();
printw("Hello");
refresh();
int c = getch();
printw("%d", c);
getch();
endwin();
return 0;
}
CMakeLists.txt
cmake_minimum_required(VERSION 3.15)
project(ncurses)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_FLAGS "-lncurses")
add_executable(lncurses main.cpp)