Skip to contentSkip to conversation

Implicit declaration of mblen

Buildroot Kees van Unen 4 participants 11 messages Oct 21, 2017 – Oct 24, 2017

lore
Share & tools
lore
#0 lore raw

Hi,

I am using buildroot-2017.08 and I want to use X.org. When compiling xlib_libX11-1.6.5 there is an error in imCallbk.c: implicit declaration of function mblen. By adding a -I reference to CFLAGS in the relevant Makefile to stdlib.h this source compiles. This happens for a number of X11 sources. Does anybody knows how this can be solved with Buildroot?

The mblen bug also appears later on in the process when it tries to use xlib_libx.so.

Thank you.

--
Sent from: http://buildroot-busybox.2317881.n4.nabble.com/

#1 lore raw
Quoted 11 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Kees" == Kees van Unen <[email protected]> writes:

Hi,
I am using buildroot-2017.08 and I want to use X.org. When compiling xlib_libX11-1.6.5 there is an error in imCallbk.c: implicit declaration of function mblen. By adding a -I reference to CFLAGS in the relevant Makefile to stdlib.h this source compiles. This happens for a number of X11 sources. Does anybody knows how this can be solved with Buildroot?

The mblen bug also appears later on in the process when it tries to use xlib_libx.so.

The cross compiler should find stdlib.h without any special -I flags. Can you post your defconfig file (run make savedefconfig to generate it) and the exact error message you are seeing?

Signature · 1 line
Bye, Peter Korsgaard
#3 lore raw
Quoted 2 lines · Kees van Unen

raspberrypi0_defconfig.raspberrypi0_defconfig
<http://buildroot-busybox.2317881.n4.nabble.com/file/t2263/raspberrypi0_defconfig.raspberrypi0_defconfig>

This line looks pretty suspicious:

BR2_EXTRA_GCC_CONFIG_OPTIONS="-I/home/pi/Downloads/buildroot-2017.08/output/host/bassie"

Maybe that causes a wrong stlib.h somewhere?

Regards,
Arnout

Quoted 21 lines

mblen_error.mblen_error
<http://buildroot-busybox.2317881.n4.nabble.com/file/t2263/mblen_error.mblen_error>

Hi Peter,

Thanks for your response. Uploaded defconfig en file with the error message. Thanks.

Bye,
Kees

--
Sent from: http://buildroot-busybox.2317881.n4.nabble.com/
_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
#4 lore raw
Quoted 5 lines

This line looks pretty suspicious:

BR2_EXTRA_GCC_CONFIG_OPTIONS="-I/home/pi/Downloads/buildroot-2017.08/output/host/bassie"

Maybe that causes a wrong stlib.h somewhere?

Quoted line was leftover from test. Uploaded new defconfig with same issue.

Kees

mblen_error.mblen_error
<http://buildroot-busybox.2317881.n4.nabble.com/file/t2263/mblen_error.mblen_error>
raspberrypi0_defconfig.raspberrypi0_defconfig
<http://buildroot-busybox.2317881.n4.nabble.com/file/t2263/raspberrypi0_defconfig.raspberrypi0_defconfig>

--
Sent from: http://buildroot-busybox.2317881.n4.nabble.com/

#5 lore raw
Quoted 6 lines · Kees van Unen
Quoted 5 lines

This line looks pretty suspicious:

BR2_EXTRA_GCC_CONFIG_OPTIONS="-I/home/pi/Downloads/buildroot-2017.08/output/host/bassie"

Maybe that causes a wrong stlib.h somewhere?

Quoted 8 lines

Quoted line was leftover from test. Uploaded new defconfig with same issue.

Kees

mblen_error.mblen_error
<http://buildroot-busybox.2317881.n4.nabble.com/file/t2263/mblen_error.mblen_error>
raspberrypi0_defconfig.raspberrypi0_defconfig
<http://buildroot-busybox.2317881.n4.nabble.com/file/t2263/raspberrypi0_defconfig.raspberrypi0_defconfig>

Hm, I tried that defconfig and it works for me...

Copy the the make command line from the xlib_libX11, append V=1 to it, and
you'll see the compilation commands. Copy the compilation command for the failing file, replace the -c with -E and the -o with some filename, so you get the preprocessed file. Then in that preprocessed file check which stdlib.h it includes. stdlib.h should be included from include/X11/Xlibint.h.

Regards,
Arnout

Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
#6 lore raw
Quoted 7 lines

Copy the the make command line from the xlib_libX11, append V=1 to it, and you'll see the compilation commands. Copy the compilation command for the failing file, replace the -c with -E and the -o with some filename, so you get
the preprocessed file. Then in that preprocessed file check which stdlib.h it
includes. stdlib.h should be included from include/X11/Xlibint.h.

Need some more help... When following steps above the following error appears:

fatal error: cannot specify -o with -c, -S or -E with multiple files.

I noticed that when executing abc_new the options -fPIC -DPIC -o .libs/imCallbk.o were automatically placed behind the compilation command

abc_old is initial compilation command
abc_new is adjusted compilation command to obtain preprocessed file

abc_old.abc_old
<http://buildroot-busybox.2317881.n4.nabble.com/file/t2263/abc_old.abc_old>
abc_new.abc_new
<http://buildroot-busybox.2317881.n4.nabble.com/file/t2263/abc_new.abc_new>

--
Sent from: http://buildroot-busybox.2317881.n4.nabble.com/

#7 lore raw
In reply to Arnout Vandecappelle
Quoted 7 lines

Copy the the make command line from the xlib_libX11, append V=1 to it, and you'll see the compilation commands. Copy the compilation command for the failing file, replace the -c with -E and the -o with some filename, so you get
the preprocessed file. Then in that preprocessed file check which stdlib.h it
includes. stdlib.h should be included from include/X11/Xlibint.h.

Hi, I managed to get the preprocessor file (see uploaded file). It includes the next stdlib.h:

output/host/arm-buildroot-linux-uclibc/gnueabihf/sysroot/usr/include/stdlib.h

In this version of stdlib.h there is no reference to mblen (see uploaded file).

Regards,
Kees

imCallbk.o
<http://buildroot-busybox.2317881.n4.nabble.com/file/t2263/imCallbk.o>
stdlib.h
<http://buildroot-busybox.2317881.n4.nabble.com/file/t2263/stdlib.h>

--
Sent from: http://buildroot-busybox.2317881.n4.nabble.com/

#8 lore raw

Hello Kees,

Quoted 16 lines · Kees van Unen
Quoted 7 lines

Copy the the make command line from the xlib_libX11, append V=1 to it, and you'll see the compilation commands. Copy the compilation command for the failing file, replace the -c with -E and the -o with some filename, so you get
the preprocessed file. Then in that preprocessed file check which stdlib.h it
includes. stdlib.h should be included from include/X11/Xlibint.h.

Hi, I managed to get the preprocessor file (see uploaded file). It includes the next stdlib.h:

output/host/arm-buildroot-linux-uclibc/gnueabihf/sysroot/usr/include/stdlib.h

In this version of stdlib.h there is no reference to mblen (see uploaded file).

Quoted 8 lines

Regards,
Kees

imCallbk.o
<http://buildroot-busybox.2317881.n4.nabble.com/file/t2263/imCallbk.o>
stdlib.h
<http://buildroot-busybox.2317881.n4.nabble.com/file/t2263/stdlib.h>

Compared against local build (git master):

seiderer at localhost:~/Work/Buildroot/build-rpi0-xlib_libX11-1.6.5-mblen-error-001> wget http://buildroot-busybox.2317881.n4.nabble.com/file/t2263/stdlib.h
seiderer at localhost:~/Work/Buildroot/build-rpi0-xlib_libX11-1.6.5-mblen-error-001> diff -u stdlib.h ./host/arm-buildroot-linux-uclibcgnueabihf/sysroot/usr/include/stdlib.h

host/arm-buildroot-linux-uclibcgnueabihf/sysroot/usr/include/stdlib.h renamed from stdlib.h +26 -1
@@ -26,6 +26,7 @@
 /* Get size_t, wchar_t and NULL from <stddef.h>.  */
 #define		__need_size_t
 #ifndef __need_malloc_and_calloc
+#  define	__need_wchar_t
 # define	__need_NULL
 #endif
 #include <stddef.h>
@@ -138,7 +139,8 @@
 #define	MB_CUR_MAX	(__ctype_get_mb_cur_max ())
 extern size_t __ctype_get_mb_cur_max (void) __THROW __wur;
 #else
-# define	MB_CUR_MAX	1
+# define	MB_CUR_MAX	(_stdlib_mb_cur_max ())
+extern size_t _stdlib_mb_cur_max (void) __THROW __wur;
 #endif
 
 
@@ -825,6 +827,29 @@
 #endif	/* use MISC || use X/Open Unix */
 
 
+__BEGIN_NAMESPACE_STD
+/* Return the length of the multibyte character
+   in S, which is no longer than N.  */
+extern int mblen (const char *__s, size_t __n) __THROW __wur;
+/* Return the length of the given multibyte character,
+   putting its `wchar_t' representation in *PWC.  */
+extern int mbtowc (wchar_t *__restrict __pwc,
+		   const char *__restrict __s, size_t __n) __THROW __wur;
+/* Put the multibyte character represented
+   by WCHAR in S, returning its length.  */
+extern int wctomb (char *__s, wchar_t __wchar) __THROW __wur;
+
+
+/* Convert a multibyte string to a wide char string.  */
+extern size_t mbstowcs (wchar_t *__restrict  __pwcs,
+			const char *__restrict __s, size_t __n) __THROW;
+/* Convert a wide char string to multibyte string.  */
+extern size_t wcstombs (char *__restrict __s,
+			const wchar_t *__restrict __pwcs, size_t __n)
+     __THROW;
+__END_NAMESPACE_STD
+
+
 #ifdef __USE_SVID
 /* Determine whether the string value of RESPONSE matches the affirmation
    or negative response expression as specified by the LC_MESSAGES category

Regards,
Peter

Quoted 11 lines

--
Sent from: http://buildroot-busybox.2317881.n4.nabble.com/
_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

#9 lore raw
Quoted 68 lines · Peter Seiderer

Hello Kees,

Quoted 16 lines · Kees van Unen
Quoted 7 lines

Copy the the make command line from the xlib_libX11, append V=1 to it, and you'll see the compilation commands. Copy the compilation command for the failing file, replace the -c with -E and the -o with some filename, so you get
the preprocessed file. Then in that preprocessed file check which stdlib.h it
includes. stdlib.h should be included from include/X11/Xlibint.h.

Hi, I managed to get the preprocessor file (see uploaded file). It includes the next stdlib.h:

output/host/arm-buildroot-linux-uclibc/gnueabihf/sysroot/usr/include/stdlib.h

In this version of stdlib.h there is no reference to mblen (see uploaded file).

Quoted 8 lines

Regards,
Kees

imCallbk.o
<http://buildroot-busybox.2317881.n4.nabble.com/file/t2263/imCallbk.o>
stdlib.h
<http://buildroot-busybox.2317881.n4.nabble.com/file/t2263/stdlib.h>

Compared against local build (git master):

seiderer at localhost:~/Work/Buildroot/build-rpi0-xlib_libX11-1.6.5-mblen-error-001> wget http://buildroot-busybox.2317881.n4.nabble.com/file/t2263/stdlib.h
seiderer at localhost:~/Work/Buildroot/build-rpi0-xlib_libX11-1.6.5-mblen-error-001> diff -u stdlib.h ./host/arm-buildroot-linux-uclibcgnueabihf/sysroot/usr/include/stdlib.h

host/arm-buildroot-linux-uclibcgnueabihf/sysroot/usr/include/stdlib.h renamed from stdlib.h +14 -1
@@ -26,6 +26,7 @@
 /* Get size_t, wchar_t and NULL from <stddef.h>.  */
 #define		__need_size_t
 #ifndef __need_malloc_and_calloc
+#  define	__need_wchar_t
 # define	__need_NULL
 #endif
 #include <stddef.h>
@@ -138,7 +139,8 @@
 #define	MB_CUR_MAX	(__ctype_get_mb_cur_max ())
 extern size_t __ctype_get_mb_cur_max (void) __THROW __wur;
 #else
-# define	MB_CUR_MAX	1
+# define	MB_CUR_MAX	(_stdlib_mb_cur_max ())
+extern size_t _stdlib_mb_cur_max (void) __THROW __wur;
 #endif
 
 
@@ -825,6 +827,29 @@
 #endif	/* use MISC || use X/Open Unix */
 
 
+__BEGIN_NAMESPACE_STD
+/* Return the length of the multibyte character
+   in S, which is no longer than N.  */
+extern int mblen (const char *__s, size_t __n) __THROW __wur;
+/* Return the length of the given multibyte character,
+   putting its `wchar_t' representation in *PWC.  */
+extern int mbtowc (wchar_t *__restrict __pwc,
+		   const char *__restrict __s, size_t __n) __THROW __wur;
+/* Put the multibyte character represented
+   by WCHAR in S, returning its length.  */
+extern int wctomb (char *__s, wchar_t __wchar) __THROW __wur;

host/arm-buildroot-linux-uclibcgnueabihf/sysroot/usr/include/stdlib.h line 850

Quoted 10 lines
host/arm-buildroot-linux-uclibcgnueabihf/sysroot/usr/include/stdlib.h renamed from stdlib.h +10 -0
+
+
+/* Convert a multibyte string to a wide char string.  */
+extern size_t mbstowcs (wchar_t *__restrict  __pwcs,
+			const char *__restrict __s, size_t __n) __THROW;
+/* Convert a wide char string to multibyte string.  */
+extern size_t wcstombs (char *__restrict __s,
+			const wchar_t *__restrict __pwcs, size_t __n)
+     __THROW;
+__END_NAMESPACE_STD

Right, so this is the bit that gets removed when BR2_TOOLCHAIN_BUILDROOT_WCHAR
is not set.

Kees, is it possible that you changed the toolchain configuration and did not
do a 'make clean'? [1]

[Rule 1 when somebody comes with a problem: did you do a make clean?]

Regards,
Arnout

[1] https://buildroot.org/downloads/manual/manual.html#full-rebuild

Quoted 26 lines
host/arm-buildroot-linux-uclibcgnueabihf/sysroot/usr/include/stdlib.h renamed from stdlib.h +2 -0
+
+
 #ifdef __USE_SVID
 /* Determine whether the string value of RESPONSE matches the affirmation
    or negative response expression as specified by the LC_MESSAGES category

Regards,
Peter

Quoted 11 lines

--
Sent from: http://buildroot-busybox.2317881.n4.nabble.com/
_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
#10 lore raw
Quoted 1 line

Kees, is it possible that you changed the toolchain configuration and did

not

Quoted 1 line

do a 'make clean'? [1]

Thanks guys. It is very well possible that I didn't do a make clean. I will do it now and try again.

Regards,
Kees

--
Sent from: http://buildroot-busybox.2317881.n4.nabble.com/