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
Why Would Anyone Use Set Instead of Unordered_Set
Determine If Map Contains a Value for a Key
C++ Concept That Requires a Member Function with an Outputiterator as Parameter
Why Does This If Condition Fail for Comparison of Negative and Positive Integers
Why Is This Constexpr Static Member Function Not Seen as Constexpr When Called
Static Control Background Color with C++
Checking for Underflow/Overflow in C++
How to Read a JSON File Containing Multiple Root Elements
Is-Braces-Constructible Type Trait
How to Create a Type in C++ That Takes Less Than One Byte of Memory
What Operators Do I Have to Overload to See All Operations When Passing an Object to a Function
Should I Use Wchar_T When Using Utf-8
Differencebetween an Empty and a Null Std::Shared_Ptr in C++
Efficiently Getting All Divisors of a Given Number
If I Want to Specialise Just One Method in a Template, How to Do It