IRIX Network Forums
Linking nekoware ncurses - Printable Version

+- IRIX Network Forums (//forums.irixnet.org)
+-- Forum: SGI/MIPS (//forums.irixnet.org/forum-3.html)
+--- Forum: Development/Porting (//forums.irixnet.org/forum-9.html)
+--- Thread: Linking nekoware ncurses (/thread-523.html)

Pages: 1 2


Linking nekoware ncurses - Trantor - 10-06-2018

Hi, I'm just starting to play with my newly installed system trying to make a simple project (nothing fancy, a z-code interpreter with ncurses support).
I'm basically done with the interpreter code, but now I have some problems when linking with the ncurses lib from nekoware.
I've made a simple "hello world" program in order to keep the things simple:

Code:
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
//extern "C" {
    #include <curses.h>
//}

int main(int argc, char *argv[])
{
    WINDOW *mainwin;

    if ((mainwin = initscr()) == NULL) {
        fprintf(stderr, "Error initializing ncurses.n");
        exit(EXIT_FAILURE);
    }

    mvaddstr(13, 33, "Hello, world!");
    refresh();
    sleep(3);

    delwin(mainwin);
    endwin();
    refresh();

    return EXIT_SUCCESS;
}

My exported variables are:

Code:
declare -x CC="c99"
declare -x CFLAGS="-O2 -mips3 -I/usr/nekoware/include -TARG:proc=r4000"
declare -x LANG="C"
declare -x LDFLAGS="-L/usr/nekoware/lib -Wl,-rpath -Wl,/usr/nekoware/lib"
declare -x LD_LIBRARY_PATH="/usr/nekoware/lib:/usr/lib32"
declare -x PATH="/usr/nekoware/bin:/usr/sbin:/usr/bsd:/sbin:/usr/bin:/usr/bin/X11:"
declare -x PS1="\\u [ \\w ]\$ "
declare -x SHELL="/usr/nekoware/bin/bash"
declare -x TERM="iris-ansi"


My compile line is:
Code:
c99 ${CFLAGS} -o curhello curhello.c ${LDFLAGS} -lncurses -v

and the error is:

Code:
Compiling main
/usr/lib32/cmplrs/be -PHASE:w:c -G8 -TARG:t5_ll_sc_bug=on -TENV:PIC -m1 -O2 -TARG:isa=mips3 -TARG:proc=r4000 -show -TARG:abi=n32 -LANG:=ansi_c -fB,/tmp/ctmB.BAAa002yq -fo,curhello.o curhello.c
Compiling curhello.c (/tmp/ctmB.BAAa002yq) -- Back End
Compiling main(0)

/usr/lib32/cmplrs/ld32 -call_shared -no_unresolved -transitive_link -elf -_SYSTYPE_SVR4 -mips3 -L/usr/nekoware/lib -rpath /usr/nekoware/lib -show -n32 -L/usr/lib32/mips3/r4000 -L/usr/lib32/mips3 -L/usr/lib32 /usr/lib32/mips3/crt1.o -o curhello curhello.o -lncurses -dont_warn_unused -Bdynamic -lc /usr/lib32/mips3/crtn.o -warn_unused
ld32: ERROR   33 : Unresolved text symbol "initscr32" -- 1st referenced by curhello.o.
       Use linker option -v to see when and which objects, archives and dsos are loaded.  
ld32: INFO    152: Output file removed because of error.
c99 ERROR:  /usr/lib32/cmplrs/ld32 returned non-zero status 2

I've installed the ncurses-5.4 from mips3 branch of nekoware. I've also tried to search for the symbol into libncurses.so:

Code:
asperi [ ~/mac/curses ]$ nm /usr/nekoware/lib/libncurses.so | grep initscr
[149]   |   6457472|     212|FUNC |GLOB |DEFAULT  |MIPS_TEXT|initscr

and it seems to be here.

Any clues on how to solve this problem?


RE: Linking nekoware ncurses - dexter1 - 10-06-2018

I can confirm this as well. You can actually link with the old IRIX curses library and the demo will run.

I am currently compiling neko_ncurses 6.1 on my R4K machine and will test it out this afternoon


RE: Linking nekoware ncurses - Trantor - 10-06-2018

Ah! I think I've solved it!
Actually if I change the includes to

Code:
#include <ncurses/ncurses.h>

it compiles without problems. I think that the problem was that there is a /usr/include/curses.h as a Irix system curses implementation, and the "curses.h" from ncurses is located in /usr/nekoware/include/ncurses/curses.h.

Biggrin


RE: Linking nekoware ncurses - dexter1 - 10-06-2018

Indeed, i overlooked the fact that you included the curses.h header, which is why it does work with IRIX' -lcurses

There is a ncurses/curses.h header as well and is used as a compatibility header for older packages, be aware of that.


RE: Linking nekoware ncurses - Trantor - 10-06-2018

Thanks!
Btw, does Irix supports color terminals? I've made another sample program with ncurses that should put some colors on screen and it reports that it does not have colors.


RE: Linking nekoware ncurses - dexter1 - 10-06-2018

The standard IRIX "Winterm" xwsh terminal has ansi escape color sequence support. Are you using that terminal? The standard IRIX xterm does not, well, not fully.

It could be that ncurses misinterrogates the terminal settings, or finds an unknown terminal in the TERM environment variable.


RE: Linking nekoware ncurses - Trantor - 10-06-2018

Yes, I've tried with WinTerm, the standard console and aterm from nekoware. Can be related to the fact the the environment reports that TERM="iris-ansi" ?


RE: Linking nekoware ncurses - dexter1 - 10-06-2018

It might. Try setting it to "xterm"


RE: Linking nekoware ncurses - Trantor - 10-06-2018

Ok, now it seems to work! The correct value for the TERM env var is "xterm-16color". The side effect of this is that vi does not recognize this terminal type and screw it a little bit. I think I'll switch to neko vim and retest it.
Thank you dexter1 for your help Smile


RE: Linking nekoware ncurses - dexter1 - 10-06-2018

You're welcome, and good to see you're getting somewhere even with the 'old' mips3 versions of nekoware.

I'm (slowly) putting together a new incarnation of nekoware with both mips3 and mips4 support and will host it somewhere. There is a little bit of the new stuff at http://ftp.irisware.net/pub/nekoware/dual-mips3-mips4/