Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installing fails with 'multiple definition' during shared library building #5

Closed
drok opened this issue Mar 27, 2020 · 1 comment
Closed

Comments

@drok
Copy link

drok commented Mar 27, 2020

As a first time user of dmalloc 5.5.2, I encountered the following "multiple definition" error while building the shared library target "installsl":

bc6:radu [Linux] /tmp/dmalloc
$ ./configure --prefix=/tmp/dmalloc-root/usr
[... success ...]
$ make install installsl
rm -f dmalloc.h dmalloc.h.t
cat ./dmalloc.h.1 dmalloc.h.2 ./dmalloc.h.3 > dmalloc.h.t
mv dmalloc.h.t dmalloc.h
./mkinstalldirs /tmp/dmalloc-root/usr/include
/usr/bin/install -c -m 644 dmalloc.h /tmp/dmalloc-root/usr/include
rm -f arg_check.o
gcc -g -O2  -DHAVE_STDARG_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_UNISTD_H=1 -DHAVE_SYS_MMAN_H=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_W32API_WINBASE_H=0 -DHAVE_W32API_WINDEF_H=0 -DHAVE_SYS_CYGWIN_H=0 -DHAVE_SIGNAL_H=1  -I. -I.  -c arg_check.c -o ./arg_check.o
rm -f compat.o
gcc -g -O2  -DHAVE_STDARG_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_UNISTD_H=1 -DHAVE_SYS_MMAN_H=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_W32API_WINBASE_H=0 -DHAVE_W32API_WINDEF_H=0 -DHAVE_SYS_CYGWIN_H=0 -DHAVE_SIGNAL_H=1  -I. -I.  -c compat.c -o ./compat.o
rm -f dmalloc_rand.o
gcc -g -O2  -DHAVE_STDARG_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_UNISTD_H=1 -DHAVE_SYS_MMAN_H=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_W32API_WINBASE_H=0 -DHAVE_W32API_WINDEF_H=0 -DHAVE_SYS_CYGWIN_H=0 -DHAVE_SIGNAL_H=1  -I. -I.  -c dmalloc_rand.c -o ./dmalloc_rand.o
rm -f dmalloc_tab.o
gcc -g -O2  -DHAVE_STDARG_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_UNISTD_H=1 -DHAVE_SYS_MMAN_H=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_W32API_WINBASE_H=0 -DHAVE_W32API_WINDEF_H=0 -DHAVE_SYS_CYGWIN_H=0 -DHAVE_SIGNAL_H=1  -I. -I.  -c dmalloc_tab.c -o ./dmalloc_tab.o
rm -f env.o
gcc -g -O2  -DHAVE_STDARG_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_UNISTD_H=1 -DHAVE_SYS_MMAN_H=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_W32API_WINBASE_H=0 -DHAVE_W32API_WINDEF_H=0 -DHAVE_SYS_CYGWIN_H=0 -DHAVE_SIGNAL_H=1  -I. -I.  -c env.c -o ./env.o
rm -f heap.o
gcc -g -O2  -DHAVE_STDARG_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_UNISTD_H=1 -DHAVE_SYS_MMAN_H=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_W32API_WINBASE_H=0 -DHAVE_W32API_WINDEF_H=0 -DHAVE_SYS_CYGWIN_H=0 -DHAVE_SIGNAL_H=1  -I. -I.  -c heap.c -o ./heap.o
rm -f chunk.o
gcc -g -O2  -DHAVE_STDARG_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_UNISTD_H=1 -DHAVE_SYS_MMAN_H=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_W32API_WINBASE_H=0 -DHAVE_W32API_WINDEF_H=0 -DHAVE_SYS_CYGWIN_H=0 -DHAVE_SIGNAL_H=1  -I. -I.  -c chunk.c -o ./chunk.o
rm -f error.o
gcc -g -O2  -DHAVE_STDARG_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_UNISTD_H=1 -DHAVE_SYS_MMAN_H=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_W32API_WINBASE_H=0 -DHAVE_W32API_WINDEF_H=0 -DHAVE_SYS_CYGWIN_H=0 -DHAVE_SIGNAL_H=1  -I. -I.  -c error.c -o ./error.o
rm -f malloc.o
gcc -g -O2  -DHAVE_STDARG_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_UNISTD_H=1 -DHAVE_SYS_MMAN_H=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_W32API_WINBASE_H=0 -DHAVE_W32API_WINDEF_H=0 -DHAVE_SYS_CYGWIN_H=0 -DHAVE_SIGNAL_H=1  -I. -I.  -c malloc.c -o ./malloc.o
ar cr libdmalloc.a arg_check.o compat.o dmalloc_rand.o dmalloc_tab.o env.o heap.o chunk.o error.o malloc.o
ranlib libdmalloc.a
./mkinstalldirs /tmp/dmalloc-root/usr/lib
/usr/bin/install -c libdmalloc.a /tmp/dmalloc-root/usr/lib
ranlib /tmp/dmalloc-root/usr/lib/libdmalloc.a
Enter 'make installsl' to install libdmalloc.so in /tmp/dmalloc-root/usr/lib
Enter 'make installcxx' to install the C++ library
Enter 'make installth' to install thread library
rm -f dmalloc.o
gcc -g -O2  -DHAVE_STDARG_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_UNISTD_H=1 -DHAVE_SYS_MMAN_H=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_W32API_WINBASE_H=0 -DHAVE_W32API_WINDEF_H=0 -DHAVE_SYS_CYGWIN_H=0 -DHAVE_SIGNAL_H=1  -I. -I.  -c dmalloc.c -o ./dmalloc.o
rm -f dmalloc_argv.o
gcc -g -O2  -DHAVE_STDARG_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_UNISTD_H=1 -DHAVE_SYS_MMAN_H=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_W32API_WINBASE_H=0 -DHAVE_W32API_WINDEF_H=0 -DHAVE_SYS_CYGWIN_H=0 -DHAVE_SIGNAL_H=1  -I. -I.  -c dmalloc_argv.c -o ./dmalloc_argv.o
rm -f dmalloc
gcc  -o aout dmalloc.o dmalloc_argv.o compat.o env.o \
                -L.
mv aout dmalloc
./mkinstalldirs /tmp/dmalloc-root/usr/bin
/usr/bin/install -c dmalloc /tmp/dmalloc-root/usr/bin
Enter 'make installdocs' to install dmalloc.html dmalloc.texi dmalloc.pdf in /tmp/dmalloc-root/usr/share/doc/dmalloc
rm -f libdmalloc.so libdmalloc.so.t
ld -shared --whole-archive -soname libdmalloc.so -o libdmalloc.so.t libdmalloc.a arg_check.o compat.o dmalloc_rand.o dmalloc_tab.o env.o heap.o
arg_check.o: In function `_dmalloc_strlen':
/tmp/dmalloc/arg_check.c:446: multiple definition of `_dmalloc_strlen'
libdmalloc.a(arg_check.o):/tmp/dmalloc/arg_check.c:446: first defined here
arg_check.o: In function `_dmalloc_strtok':
/tmp/dmalloc/arg_check.c:669: multiple definition of `_dmalloc_strtok'
libdmalloc.a(arg_check.o):/tmp/dmalloc/arg_check.c:669: first defined here
arg_check.o: In function `_dmalloc_strstr':
/tmp/dmalloc/arg_check.c:650: multiple definition of `_dmalloc_strstr'
libdmalloc.a(arg_check.o):/tmp/dmalloc/arg_check.c:650: first defined here

To get around it, I had to make this change to Makefile.in, which allowed the installation:

diff --git a/Makefile.in b/Makefile.in
index f49c6f9..a60f139 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -302,7 +302,7 @@ shlib : $(BUILD_SL)
 # via: http://256.com/gray/email.html
 $(LIB_SL) : $(LIBRARY)
        rm -f $@ $@.t
-       @shlinkargs@ $(LIBRARY) $(OBJS) $(NORMAL_OBJS)
+       @shlinkargs@ $(LIBRARY)
        mv $@.t $@

 $(LIBRARY) : $(OBJS) $(NORMAL_OBJS)
@@ -315,7 +315,7 @@ $(LIB_TH) : $(OBJS) $(THREAD_OBJS)

 $(LIB_TH_SL) : $(LIB_TH)
        rm -f $@ $@.t
-       @shlinkargs@ $(LIB_TH) $(OBJS) $(THREAD_OBJS)
+       @shlinkargs@ $(LIB_TH)
        mv $@.t $@

 $(LIB_CXX) : $(OBJS) $(NORMAL_OBJS) $(CXX_OBJS)

This may be related to #4 as the unit test that triggers that issue is linked against the shared library built with the patch above.

@j256 j256 changed the title Installing fails with 'multiple definition' Installing fails with 'multiple definition' during shared library building Dec 17, 2020
@j256
Copy link
Owner

j256 commented Dec 23, 2020

I think fixed by #39

@j256 j256 closed this as completed Dec 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants