Discussion:
Module dependency problems ?
Tim Ruehsen
2018-02-14 21:25:56 UTC
Permalink
Hi,

I see these linker warnings:

undefined reference to `rpl_fclose'
undefined reference to `rpl_nanosleep'

and I don't see what's wrong, looks like I need some help.

From the extra/Makefile:
# Reproduce by: gnulib-tool --import --local-dir=extra/override --
lib=libextra --source-base=extra --m4-base=extra/m4 --
doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-
dependencies --libtool --macro-prefix=extra c-ctype
c-strcase c-strcasestr cond dirname gettext-h gettime limits-h
nanosleep sockets thread

I am using libtool for creating a libextra.la, if that matters.

After 'make', in extra/ there is no nanosleep.[l]o, just the .c file.

Any idea what is going on here ?

Regards, Tim
Bruno Haible
2018-02-14 21:44:06 UTC
Permalink
Hi Tim,
Post by Tim Ruehsen
undefined reference to `rpl_fclose'
undefined reference to `rpl_nanosleep'
and I don't see what's wrong, looks like I need some help.
# Reproduce by: gnulib-tool --import --local-dir=extra/override --
lib=libextra --source-base=extra --m4-base=extra/m4 --
doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-
dependencies --libtool --macro-prefix=extra c-ctype
c-strcase c-strcasestr cond dirname gettext-h gettime limits-h
nanosleep sockets thread
I am using libtool for creating a libextra.la, if that matters.
After 'make', in extra/ there is no nanosleep.[l]o, just the .c file.
Sorry, but that's too little information to even begin an analysis.

Typically you debug it like this, from two ends:
A.
1. Determine, by looking at the configure output and the gnulib documentation
and the corresponding .m4 file, whether a gnulib override of fclose() is
meant to be provided by gnulib.
2. Look at the values of the AC_SUBSTed variables HAVE_FCLOSE, REPLACE_FCLOSE
etc. in config.status. (I hope you have only one config.status!)

B.
1. Find out the .o file which is containing the undefined reference
to rpl_fclose.
2. Use 'nm' to get an overview of the symbols required and provided by this
object file.
3. Compile its source with "gcc -E" to see the preprocessed source code and
with "gcc -E -dM | sort" to see the macros in effect.

And similarly for rpl_nanosleep.

Bruno
Tim Rühsen
2018-02-15 09:03:07 UTC
Permalink
 


With Best Regards, Tim
Post by Bruno Haible
Hi Tim,
Post by Tim Ruehsen
undefined reference to `rpl_fclose'
undefined reference to `rpl_nanosleep'
and I don't see what's wrong, looks like I need some help.
# Reproduce by: gnulib-tool --import --local-dir=extra/override --
lib=libextra --source-base=extra --m4-base=extra/m4 --
doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-
dependencies --libtool --macro-prefix=extra c-ctype
c-strcase c-strcasestr cond dirname gettext-h gettime limits-h
nanosleep sockets thread
I am using libtool for creating a libextra.la, if that matters.
After 'make', in extra/ there is no nanosleep.[l]o, just the .c file.
Sorry, but that's too little information to even begin an analysis.
A.
1. Determine, by looking at the configure output and the gnulib documentation
and the corresponding .m4 file, whether a gnulib override of fclose() is
meant to be provided by gnulib.
2. Look at the values of the AC_SUBSTed variables HAVE_FCLOSE, REPLACE_FCLOSE
etc. in config.status. (I hope you have only one config.status!)
What do you means with "only one config.status" ? gnulib-tool is called
twice - maybe there is a conflict ?

# Reproduce by: gnulib-tool --import --dir=. --local-dir=gl --lib=libgnu
--source-base=lib/ --m4-base=m4/ --doc-base=doc --tests-base=tests
--aux-dir=build-aux --makefile-name=gnulib.mk
--no-conditional-dependencies --libtool --macro-prefix=gl accept bind
calloc-posix canonicalize-lgpl clock-time close closedir cond connect
crypto/md2 crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dirname
dup2 errno fclose fcntl fdopen fflush flock fnmatch-gnu fopen fstat
fsync ftruncate futimens getaddrinfo getpass getsockname gettext-h
gettime gitlog-to-changelog glob iconv inet_pton inline inttypes ioctl
isatty lib-symbol-visibility limits-h listen lock maintainer-makefile
malloc-posix memchr mkdir mkstemp msvc-nothrow nanosleep netdb
netinet_in nl_langinfo open opendir pipe-posix progname popen poll
posix_spawn pwrite qsort_r random_r read readdir realloc-posix recv
recvfrom regex rename safe-read safe-write select send sendto servent
setlocale setsockopt socket sockets socklen spawn-pipe stdarg stdbool
stddef stdint stat strcase strchrnul strdup-posix strerror strndup
strstr strtoll sys_file sys_socket sys_stat sys_time sys_types thread
time_r unistd unlink warnings write

# Reproduce by: gnulib-tool --import --local-dir=extra/override
--lib=libextra --source-base=extra --m4-base=extra/m4 --doc-base=doc
--tests-base=tests --aux-dir=build-aux --no-conditional-dependencies
--libtool --macro-prefix=extra c-ctype c-strcase c-strcasestr cond
dirname gettext-h gettime limits-h nanosleep sockets thread


Let's first stick with nanosleep (there is just one occurrence).

The appropriate C file uses nanosleep and includes the right include
from gnulib (extra/time.h) and thus uses rpl_nanosleep(). The link step
also correctly uses ../extra/.libs/libextra.a (that exists). This seems
all to be correct.

But as I said, in extra/ the nanosleep.o is not created by 'make' and
thus rpl_nanosleep() is missing in libextra.a. So I guess it's a matter
of the generated Makefile.

$ grep nanosleep extra/Makefile.am
## begin gnulib module nanosleep
EXTRA_DIST += nanosleep.c
EXTRA_libextra_la_SOURCES += nanosleep.c
## end gnulib module nanosleep

In comparison, gettime is built correctly:
$ grep gettime extra/Makefile.am
## begin gnulib module gettime
libextra_la_SOURCES += gettime.c
## end gnulib module gettime

So the question is why is nanosleep.o / nansleep.lo not being built ?



$ grep -i nanosleep config.h
/* Define to 1 when the gnulib module nanosleep should be tested. */
#define GNULIB_TEST_NANOSLEEP 1
/* Define to 1 if nanosleep mishandles large arguments. */
#define HAVE_BUG_BIG_NANOSLEEP 1

$ grep -i nanosleep config.status
"o nanosleep.lo nl_langinfo.lo printf-args.lo printf-parse.lo vasnprintf.lo"
S["gl_LIBOBJS"]=" asnprintf.o fclose.o fcntl.o fflush.o fpurge.o fseek.o
fseeko.o glob.o glob_pattern_p.o globfree.o ioctl.o localtime-buffer.o
mbrtowc.o nanosleep.o"\
S["LIB_NANOSLEEP"]=""
S["REPLACE_NANOSLEEP"]="1"
S["HAVE_NANOSLEEP"]="1"
S["GNULIB_NANOSLEEP"]="1"
D["HAVE_BUG_BIG_NANOSLEEP"]=" 1"
D["GNULIB_TEST_NANOSLEEP"]=" 1"


Regards, Tim

Loading...