I've recently returned to Xubuntu 22.04 after a brief stint on Fedora.
Under Fedora, I seemed to be able to install ncurses okay.
I could then simply write code and compile with commands like:
$gcc -lncurses main.c
Now, when I try that, it gives me:
/usr/bin/ld: /tmp/cczC1PpK.o: in function `main':
main.c:(.text+0x9): undefined reference to `initscr'
/usr/bin/ld: main.c:(.text+0x1d): undefined reference to `printw'
/usr/bin/ld: main.c:(.text+0x24): undefined reference to `stdscr'
/usr/bin/ld: main.c:(.text+0x2c): undefined reference to `wgetch'
/usr/bin/ld: main.c:(.text+0x31): undefined reference to `endwin'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status
I have tried installing using the following:
sudo apt-get install libncurses5-dev libncursesw5-dev
sudo apt-get install ncurses-dev libncurses5-dev libncursesw5-dev
sudo apt-get install libncurses5 libncurses5:i386
sudo apt-get install libncurses5:i386
All appear to install well with no errors or warnings.
And yet, my code simply doesn't recognise the ncurses function.
The code is as follows:
#include <stdio.h>
#include <ncurses.h>
int main()
{
initscr();
printw("Hello World!");
getch();
endwin();
return 0;
}
It's so simple, and yet it fails.
Any ideas?
Thanks.