Undefined Reference to 'Stdscr' While Using Ncurses

Linking error: undefined references to stdscr and wgetch

Try this.

g++ foo.cpp -lncurses

You have to link ncurses to your program since it is not a standard header file. You may also have to install it if you don't have it. I had the same issue making a terminal based game when I was first learning c++

Undefined reference to stdscr

You could use -lcurses. Ex: gcc main.c -o demo -lcurses

ncurses & curses - compiler undefined references

You're not linking against the curses library. You need to provide -lncurses to the line that links your executable in your makefile.

Undefined reference to `initscr' Ncurses

You need to change your makefile so that the -lncurses directive comes after your object code on the gcc command line, i.e. it needs to generate the command:

gcc -W -Wall -Werror -Wextra -I./Includes/. -o Sources/NCurses/ncurses_init.o -c Sources/NCurses/ncurses_init.c -lncurses

This is because object files and libraries are linked in order in a single pass.

Undefined reference during linking using ncurses and cmake

From documentation of CMAKE, you need to specify files not directory for target_link_libraries. So something like

target_link_libraries(LearnC curses)

https://cmake.org/cmake/help/v2.8.12/cmake.html#command%3atarget_link_libraries



Related Topics



Leave a reply



Submit