compiler confuzzlement

G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

I tried to compile the following code:

#include <ncurses.h>

int main()
{
initscr();
printw("Hello World!!!");
refresh();
getch();
endwin();

return (0);
}

and got the following error messages:

unbinder@Julian:~$ g++ -o nimrl ~/stories/code/nimrl.cpp
/home/unbinder/stories/code/nimrl.cpp:12:2: warning: no newline at end
of file
/tmp/ccuBixdB.o(.text+0x11): In function `main':
: undefined reference to `initscr'
/tmp/ccuBixdB.o(.text+0x1d): In function `main':
: undefined reference to `printw'
/tmp/ccuBixdB.o(.text+0x22): In function `main':
: undefined reference to `refresh'
/tmp/ccuBixdB.o(.text+0x27): In function `main':
: undefined reference to `stdscr'
/tmp/ccuBixdB.o(.text+0x2f): In function `main':
: undefined reference to `wgetch'
/tmp/ccuBixdB.o(.text+0x34): In function `main':
: undefined reference to `endwin'
collect2: ld returned 1 exit status

Is there a newsgroup dedicated to ncurses? I couldn't find one.
 
Archived from groups: rec.games.roguelike.development (More info?)

Thank you, Filip & Sheep. I will remember your kindness when i know
what i'm doing and newbies start asking me similarly obnoxious
questions :)
 
Archived from groups: rec.games.roguelike.development (More info?)

Dnia 21 Apr 2005 07:50:22 -0700,
NIm napisal(a):

> I tried to compile the following code:
<snip>
> and got the following error messages:

> unbinder@Julian:~$ g++ -o nimrl ~/stories/code/nimrl.cpp
<snip>

try this:
unbinder@Julian:~$ g++ -lncurses -onimrl ~/stories/code/nimrl.cpp

--
Radomir @**@_ Bee! .**._ .**._ .**._ .**._ zZ
`The Sheep' ('') 3 (..) 3 (..) 3 (..) 3 (--) 3
Dopieralski .vvVvVVVVVvVVVvVVVvVvVVvVvvVvVVVVVVvvVVvvVvvvvVVvVVvv.v.
 
Archived from groups: rec.games.roguelike.development (More info?)

Uzytkownik "NIm" <bladedpenguin@yahoo.com> napisal w wiadomosci
news:1114095022.455465.97840@z14g2000cwz.googlegroups.com...
>I tried to compile the following code:

You forgot to link it with curses library. Header files in C++ are not
like "import" or "using" from other languages, you still have to show
the linker the right object file where the curses functions can be
found. I have not programmed under Linux curses in ages, but I guess
it would be -lncurses.

regards,
Filip