sabotage-linux / netbsd-curses

libcurses and dependencies taken from netbsd and brought into a portable shape (at least to musl or glibc)
Other
147 stars 14 forks source link

Build Error: Assumed value of MB_LEN_MAX wrong #15

Closed githububub closed 8 years ago

githububub commented 8 years ago

Arch. netbsd-curses 0.0.4. Unable to complete the build process due to following error:

In file included from /usr/include/stdlib.h:925:0, from libcurses/fileio.c:41: /usr/include/bits/stdlib.h: In function ‘wctomb’: /usr/include/bits/stdlib.h:90:3: error: #error "Assumed value of MB_LEN_MAX wrong"

error "Assumed value of MB_LEN_MAX wrong"

^~~~~ cc -D_FORTIFY_SOURCE=2 -I. -I./libterminfo -DHAVE_WCHAR -I./libcurses -march=amdfam16 -O2 -pipe -fstack-protector-all -fomit-frame-pointer -Werror-implicit-function-declaration -c -o libcurses/getch.o libcurses/getch.c make: * [GNUmakefile:399: libcurses/fileio.o] Error 1 make: * Waiting for unfinished jobs.... ==> ERROR: A failure occurred in build(). Aborting...

How to resolve?

rofl0r commented 8 years ago

please try if this patch fixes it

diff --git a/libcurses/curses_private.h b/libcurses/curses_private.h
index 56ed15f..24ff401 100644
--- a/libcurses/curses_private.h
+++ b/libcurses/curses_private.h
@@ -41,6 +41,7 @@

 #include <term.h>
 #include <termios.h>
+#include <limits.h>

 /* Private structure definitions for curses. */

@@ -254,7 +255,9 @@ struct __screen {
    wchar_t *unget_list;
    int unget_len, unget_pos;
 #ifdef HAVE_WCHAR
+#ifndef MB_LEN_MAX
 #define MB_LEN_MAX 8
+#endif
 #define MAX_CBUF_SIZE MB_LEN_MAX
    int     cbuf_head;      /* header to cbuf */
    int     cbuf_tail;      /* tail to cbuf */

bonus points if you can test an app with UTF-8 display (for example nano) and confirm that everything works as expected :)

githububub commented 8 years ago

Patch allows the build to complete successfully. http://pastebin.com/HsU8SfJS.

Bash on Arch expects libncursesw.so.6 so a single symlink with libcurses.so was created = Bash works as expected though an error dialog appears:

ldconfig: /usr/lib/libcurses.so is not a symbolic link

Likely due to library versioning where libncursesw.so is symlinked to libncursesw.so.6 which in turn is symlinked to libncursesw.so.6.0.

Unable to run nano 2.7.0 built against ncurses 6.0 with netbsd-curses installed as ncurses dependency:

$ nano nano: symbol lookup error: nano: undefined symbol: set_escdelay

Attempting to rebuild nano also results in a failed build:

nano.o: In function main': nano.c:(.text.startup+0x579): undefined reference toset_escdelay' collect2: error: ld returned 1 exit status make[2]: *\ [Makefile:398: nano] Error 1

Arch PKGBUILD script used for the build remains a work in progress: http://pastebin.com/tRuF0FRA

rofl0r commented 8 years ago

thanks for testing. it seems weird that your ncurses-linked bash works with netbsd curses, because the latter is only API (to a very large extent) compatible, not ABI compatible.

as for nano, i am able to build nano 2.4.0 successfully against netbsd-curses. which version are you using ? it's possible that you still have the ncurses headers installed so a configure check found that set_escdelay is declared and so went on to use it.

rofl0r commented 7 years ago

@githububub the issue with nano is now fixed. there's also a new release tarball available.