QNX 6.2 & ncurses

When I compile (cc -l ncurses -o testcurses testcurses.c)

#include “curses.h”

void main()
{
initscr();
curs_set(0);
mvaddnstr (1, 1, “Hello”,5 );
refresh();
}
I get
/tmp/AAA404392_cc.o: In function main': /tmp/AAA404392_cc.o(.text+0x7): undefined reference to initscr’
/tmp/AAA404392_cc.o(.text+0x11): undefined reference to curs_set' /tmp/AAA404392_cc.o(.text+0x20): undefined reference to stdscr’
/tmp/AAA404392_cc.o(.text+0x26): undefined reference to wmove' /tmp/AAA404392_cc.o(.text+0x3f): undefined reference to stdscr’
/tmp/AAA404392_cc.o(.text+0x45): undefined reference to waddnstr' /tmp/AAA404392_cc.o(.text+0x54): undefined reference to stdscr’
/tmp/AAA404392_cc.o(.text+0x5a): undefined reference to `wrefresh’
cc: /usr/bin/ntox86-ld error 1

Please help me.
Thanks a lot.
waszcz

cc -o testcurses testcurses.c -l ncurses

also change function name from “mian” to “main” :slight_smile:

Oh, I made the mistake when wrote this simply example, but it’s no matter in my problem.

waszcz

Ok, but have u tried the compile command
cc -o testcurses testcurses.c -l ncurses
instead of yours
cc -l ncurses -o testcurses testcurses.c
?

As mezek mentioned, the order of files on the command line does matter. At the point you link in the library, there are no outstanding symbols to resolve, so nothing is linked. Then you link your object which has outstanding symbols, which are not resolved.

If you change the order, your object will have outstanding symbols, which will be resolved by the library which is linked next.

Rick…

Thank you. I would never have found it all by myself.

Thanks Rick for explanation.

waszcz

qnx.com/developers/docs/mome … q/qcc.html and same page in 6.2.1 helpviewer have a note on “resolve order in single-pass linker” but still many people, who are used to use a IDE or recursive linker, get confused by this error (me included :slight_smile: