Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Linking nekoware ncurses
#1
Linking nekoware ncurses
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?
Trantor Offline
O2

Posts: 19
Threads: 3
Joined: Sep 2018
Find Reply
10-06-2018, 12:19 PM
#2
RE: Linking nekoware ncurses
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
dexter1 Offline
Global Moderator
******

Posts: 129
Threads: 8
Joined: May 2018
Find Reply
10-06-2018, 12:42 PM
#3
RE: Linking nekoware ncurses
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.

Big Grin
Trantor Offline
O2

Posts: 19
Threads: 3
Joined: Sep 2018
Find Reply
10-06-2018, 12:50 PM
#4
RE: Linking nekoware ncurses
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.
dexter1 Offline
Global Moderator
******

Posts: 129
Threads: 8
Joined: May 2018
Find Reply
10-06-2018, 12:53 PM
#5
RE: Linking nekoware ncurses
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.
Trantor Offline
O2

Posts: 19
Threads: 3
Joined: Sep 2018
Find Reply
10-06-2018, 12:56 PM
#6
RE: Linking nekoware ncurses
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.
(This post was last modified: 10-06-2018, 01:41 PM by dexter1.)
dexter1 Offline
Global Moderator
******

Posts: 129
Threads: 8
Joined: May 2018
Find Reply
10-06-2018, 01:36 PM
#7
RE: Linking nekoware ncurses
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" ?
Trantor Offline
O2

Posts: 19
Threads: 3
Joined: Sep 2018
Find Reply
10-06-2018, 01:40 PM
#8
RE: Linking nekoware ncurses
It might. Try setting it to "xterm"
dexter1 Offline
Global Moderator
******

Posts: 129
Threads: 8
Joined: May 2018
Find Reply
10-06-2018, 01:50 PM
#9
RE: Linking nekoware ncurses
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
Trantor Offline
O2

Posts: 19
Threads: 3
Joined: Sep 2018
Find Reply
10-06-2018, 02:07 PM
#10
RE: Linking nekoware ncurses
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/
dexter1 Offline
Global Moderator
******

Posts: 129
Threads: 8
Joined: May 2018
Find Reply
10-06-2018, 02:13 PM


Forum Jump:


Users browsing this thread: 1 Guest(s)