LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-04-2017, 02:39 PM   #1
bastl
Member
 
Registered: Sep 2003
Location: Germany/BW
Distribution: My own
Posts: 237

Rep: Reputation: 22
Red face 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:
Quote:
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:
Code:
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!
 
Old 03-06-2017, 02:06 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,830

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
__asprintf_chk is available in /lib/x86_64-linux-gnu/libc.so.6 (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).
 
Old 06-24-2017, 11:15 AM   #3
bastl
Member
 
Registered: Sep 2003
Location: Germany/BW
Distribution: My own
Posts: 237

Original Poster
Rep: Reputation: 22
Compiling coreutils worked with:
Quote:
export CFLAGS="-D_FORTIFY_SOURCE=0"
even with
Quote:
export CFLAGS="-g -O2 -D_FORTIFY_SOURCE=1"
you'll get other checks fail.

so -D_FORTIFY_SOURCE=0 worked for me.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
C++ undefined reference grob115 Programming 4 01-22-2013 11:22 AM
Yet another undefined reference CollieJim Linux - General 2 12-17-2010 11:08 PM
undefined reference to.... crapodino Programming 1 01-13-2008 07:05 PM
undefined reference to... dimah Programming 3 12-27-2006 09:57 AM
undefined reference? Sharky01252 Programming 3 11-07-2006 11:36 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:05 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration