Skip to content
Sign upLog in
← Back to Community

They've done it, everyone. You can now use ncurses on replit via the shell.

Profile icon
SPQR

The repl.it team made some changes to the compiler this morning. You can now compile via clang if you use the shell (accessible via the command palette.) Now you can make and run an ncurses program in just three easy steps! (steps shown are for c++)

  1. #include <ncurses.h>
  2. enter "clang -std=c++11 -lncurses main.cpp -o main" into the shell to compile
  3. enter "/home/runner/main" into the shell to run
    And enjoy!
    note: this will run the program in the shell window instead of the normal run window, so keep that in mind. Also, I'm not sure if this works with repl.run yet. Also Also, you can just do step#3 to run your program again w/o applying any changes to the source.

Major props to the repl.it fellows for this one.

Voters
Profile icon
VincentEkstrm
Profile icon
devgabuette
Profile icon
PaoloAmoroso
Profile icon
abc3354
Profile icon
SPQR
Comments
hotnewtop
Profile icon
tomekjaworski

There should be some configution functionality to add libraries.

clang++-7 -pthread -std=c++11 -o main main.cpp /tmp/main-6026d9.o: In function `main': main.cpp:(.text+0x10): undefined reference to `initscr' main.cpp:(.text+0x19): undefined reference to `cbreak' main.cpp:(.text+0x21): undefined reference to `noecho' main.cpp:(.text+0x40): undefined reference to `stdscr' main.cpp:(.text+0x45): undefined reference to `wgetch' main.cpp:(.text+0x74): undefined reference to `refresh' clang: error: linker command failed with exit code 1 (use -v to see invocation) compiler exit status 1
Profile icon
SPQR

@tomekjaworski
Are you just clicking "run"? because that won't work, you have to paste clang -std=c++11 -lncurses main.cpp -o main into the shell, and then /home/runner/main to run, for this particular program at least.

Profile icon
tomekjaworski

@SPQR
Yes, I;m using the shell command line. However I was wandering is there a config entry in which I can specify compiler parameters (like list of libs to link)?

Profile icon
SPQR

@tomekjaworski
not as of right now, unless you use polygott, which uses makefile syntax

Profile icon
beaver700nh

@tomekjaworski
make a file called .replit in the root directory and put this in it: run=""

Profile icon
beaver700nh

@beaver700nh
I meant home directory not root

Profile icon
nsharan2000

i am also getting the same error. it also says /home/runner/main directory is not found when I try to run it


@SPQR

Profile icon
BenjaminMcMulle

This will not work for me. I've tried running every command in the shell, I've included -lncurses, I've used the g++ and clang compiler, but leading to no avail. I copied and pasted the entire source of this project and nothing.

Profile icon
BenjaminMcMulle

@BenjaminMcMulle

The error I get is below:
main.cpp:2:10: fatal error: ncurses.h: No such file or directory
2 | #include <ncurses.h>
| ^~~~~~~~~~~
compilation terminated.

Profile icon
abc3354

Cool !