Search code examples
c++xcodeterminalncurses

Running main.cpp file in terminal with ncurse header


I am using the ncurse.h header file to make a snake game, however since you can't simply run a game in xcode, I've tried opening it up and running it in the terminal but the terminal spits out a lot of errors. I've tried reading through this to see if theres any information I can get out of it to resolve in my actual program, but there is nothing of relevance in there that I can find. I tried adding the -lncurses to the compiler flag in the build phases section of my xcode program but that doesn't do anything as far as I can tell.

UPDATE: I've now tried using g++ main.cpp -o pocs -lncurses which has resolved all of my errors, however when I execute the program and then access it in terminal and paste the command, nothing happens. Perhaps its something wrong with my syntax in the program itself?


Solution

  • You are specifying main.cpp twice:

    g++ main.cpp -lncurses -o pocs main.cpp
        ^^^^^^^^                   ^^^^^^^^
    

    Hence the dupes. Drop the second from the command line:

    g++ main.cpp -o pocs -lncurses