-   Linux - Software (
-   -   coreutils-8.26, undefined reference to `__asprintf_chk' (

bastl 03-04-2017 02:39 PM

coreutils-8.26, undefined reference to `__asprintf_chk'
Compiling coreutils-8.26 with gcc-6.3.0 and linux-4.8.12,
I get this error:

AR src/libver.a
AR lib/libcoreutils.a
CCLD src/chroot
CCLD src/nice
CCLD src/who
CCLD src/hostid
CCLD src/users
src/who.o: In function `asprintf':
/usr/include/bits/stdio2.h:178: undefined reference to `__asprintf_chk'
collect2: error: ld returned 1 exit status
asprintf is defined in stdio2.h here:

156 ...
# ifdef __USE_GNU

extern int __asprintf_chk (char **__restrict __ptr, int __flag,
                          const char *__restrict __fmt, ...)
    __THROW __attribute__ ((__format__ (__printf__, 3, 4))) __wur;
extern int __vasprintf_chk (char **__restrict __ptr, int __flag,
                            const char *__restrict __fmt, _G_va_list __arg)
    __THROW __attribute__ ((__format__ (__printf__, 3, 0))) __wur;
extern int __obstack_printf_chk (struct obstack *__restrict __obstack,
                                int __flag, const char *__restrict __format,
    __THROW __attribute__ ((__format__ (__printf__, 3, 4)));
extern int __obstack_vprintf_chk (struct obstack *__restrict __obstack,
                                  int __flag,
                                  const char *__restrict __format,
                                  _G_va_list __args)
    __THROW __attribute__ ((__format__ (__printf__, 3, 0)));

#  ifdef __va_arg_pack
__fortify_function int
__NTH (asprintf (char **__restrict __ptr, const char *__restrict __fmt, ...))
  return __asprintf_chk (__ptr, __USE_FORTIFY_LEVEL - 1, __fmt,
                        __va_arg_pack ());

__fortify_function int
__NTH (__asprintf (char **__restrict __ptr, const char *__restrict __fmt,
  return __asprintf_chk (__ptr, __USE_FORTIFY_LEVEL - 1, __fmt,
                        __va_arg_pack ());

__fortify_function int
__NTH (obstack_printf (struct obstack *__restrict __obstack,
                      const char *__restrict __fmt, ...))
  return __obstack_printf_chk (__obstack, __USE_FORTIFY_LEVEL - 1, __fmt,
                              __va_arg_pack ());
#  elif !defined __cplusplus
#  define asprintf(ptr, ...) \
  __asprintf_chk (ptr, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__)
#  define __asprintf(ptr, ...) \
  __asprintf_chk (ptr, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__)
#  define obstack_printf(obstack, ...) \
  __obstack_printf_chk (obstack, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__)
#  endif
204 ...

It seams that coreutils does not need __asprintf_chk but linux in its files that are included.?
I think the question is what does linux expect to get the header definitions linked ? ....
O.K. it is glibc what else; the min. version I don`t know, but mine is to old for linux-4.8.12. Damn!

pan64 03-06-2017 02:06 AM

__asprintf_chk is available in /lib/x86_64-linux-gnu/ (at least for me), so probably -lc helps, but I don't know what is really missing from where.
include files are used only compile time, they are not linked (those are the shared objects, the .so files).

bastl 06-24-2017 11:15 AM

Compiling coreutils worked with:

even with

export CFLAGS="-g -O2 -D_FORTIFY_SOURCE=1"
you'll get other checks fail.

so -D_FORTIFY_SOURCE=0 worked for me.

All times are GMT -5. The time now is 07:41 PM.