[Zlib-devel] Explicit link to libc
John Bowler
jbowler at frontiernet.net
Sun Mar 28 13:41:51 EDT 2010
From: Enrico Weigelt
>just seen that libz is explicitly linked gainst libc (-lc).
>Isn't this automatically done by the toolchain ?
No, it depends on what $(LDSHARED) is; if it's ld or link the language runtime (in this case the C runtime) must be given explicitly.
./configure uses the linker for HP-UX, SunOS 4 and, maybe, AIX.
Perhaps patch Makefile.in to use a macro then only set that macro in the !gcc case (the else clause for the if on line 79)? See the patch at the end (note that it changes the behavior in all the gcc cases, clearly this can be avoided.)
John Bowler <jbowler at acm.org>
diff -u orig/Makefile.in test/Makefile.in
--- orig/Makefile.in 2010-03-28 10:38:53.638276400 -0700
+++ test/Makefile.in 2010-03-28 10:25:30.565859200 -0700
@@ -134,7 +134,7 @@
- at mv objs/$*.o $@
$(SHAREDLIBV): $(PIC_OBJS)
- $(LDSHARED) $(SFLAGS) -o $@ $(PIC_OBJS) -lc
+ $(LDSHARED) $(SFLAGS) -o $@ $(PIC_OBJS) $(LDSHAREDLIBC)
rm -f $(SHAREDLIB) $(SHAREDLIBM)
ln -s $@ $(SHAREDLIB)
ln -s $@ $(SHAREDLIBM)
diff -u orig/configure test/configure
--- orig/configure 2010-03-28 10:38:48.786667800 -0700
+++ test/configure 2010-03-28 10:40:45.069272100 -0700
@@ -94,6 +94,9 @@
Linux | linux | GNU | GNU/* | *BSD | DragonFly) LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map"} ;;
CYGWIN* | Cygwin* | cygwin* | OS/2* )
EXE='.exe' ;;
+ MINGW*) SFLAGS="${CFLAGS}"
+ LDSHARED=${LDSHARED-"$cc -shared"}
+ EXE='.exe' ;;
QNX*) # This is for QNX6. I suppose that the QNX rule below is for QNX2,QNX4
# (alain.bonnefoy at icbt.com)
LDSHARED=${LDSHARED-"$cc -shared -Wl,-hlibz.so.1"} ;;
@@ -117,6 +120,7 @@
else
# find system name and corresponding cc options
CC=${CC-cc}
+ LDSHAREDLIBC="${LDSHAREDLIBC-"-lc"}"
if test -z "$uname"; then
uname=`(uname -sr || echo unknown) 2>/dev/null`
fi
@@ -506,6 +510,7 @@
/^SFLAGS *=/s#=.*#=$SFLAGS#
/^LDFLAGS *=/s#=.*#=$LDFLAGS#
/^LDSHARED *=/s#=.*#=$LDSHARED#
+/^LDSHAREDLIBC *=/s#=.*#=$LDSHAREDLIBC#
/^CPP *=/s#=.*#=$CPP#
/^STATICLIB *=/s#=.*#=$STATICLIB#
/^SHAREDLIB *=/s#=.*#=$SHAREDLIB#
More information about the Zlib-devel
mailing list