From: Olivier Blin Date: Sun, 29 Jul 2012 16:44:53 +0000 (-0400) Subject: Link shared libraries with local libraries instead of system ones X-Git-Tag: v1.42.5~6 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a7c17431b9;p=thirdparty%2Fe2fsprogs.git Link shared libraries with local libraries instead of system ones ELF_OTHER_LIBS usually contains local search dirs (-L ../..), but it was added in link command after system search dirs from LDFLAGS. Libraries and executables were linked with the system libraries if present, and possibly using static archives instead of shared libraries. It could also make final executable link to fail when shared libraries are enabled: if libext2fs.so is linked with a static libcom_err.a from system, build system would attempt to link without -lpthread. This fixes the issue by moving ELF_OTHER_LIBS before LDFLAGS in the link command. Addresses-Sourceforge-Bug: #3542572 Reported-by: Olivier Blin Signed-off-by: Theodore Ts'o --- diff --git a/lib/Makefile.elf-lib b/lib/Makefile.elf-lib index c24636ccc..c66281c80 100644 --- a/lib/Makefile.elf-lib +++ b/lib/Makefile.elf-lib @@ -24,8 +24,8 @@ image: $(ELF_LIB) $(ELF_LIB): $(OBJS) $(E) " GEN_ELF_SOLIB $(ELF_LIB)" - $(Q) (cd elfshared; $(CC) --shared -o $(ELF_LIB) $(LDFLAGS) \ - -Wl,-soname,$(ELF_SONAME) $(OBJS) $(ELF_OTHER_LIBS)) + $(Q) (cd elfshared; $(CC) --shared -o $(ELF_LIB) $(ELF_OTHER_LIBS) \ + $(LDFLAGS) -Wl,-soname,$(ELF_SONAME) $(OBJS)) $(Q) $(MV) elfshared/$(ELF_LIB) . $(Q) $(RM) -f ../$(ELF_LIB) ../$(ELF_IMAGE).so ../$(ELF_SONAME) $(Q) (cd ..; $(LN) $(LINK_BUILD_FLAGS) \ diff --git a/lib/Makefile.solaris-lib b/lib/Makefile.solaris-lib index 92bdbe28e..66f2b4c88 100644 --- a/lib/Makefile.solaris-lib +++ b/lib/Makefile.solaris-lib @@ -24,8 +24,8 @@ image: $(ELF_LIB) $(ELF_LIB): $(OBJS) $(E) " GEN_ELF_SOLIB $(ELF_LIB)" - $(Q) (cd elfshared; $(CC) --shared -o $(ELF_LIB) $(LDFLAGS) \ - -Wl,-h,$(ELF_SONAME) $(OBJS) $(ELF_OTHER_LIBS)) + $(Q) (cd elfshared; $(CC) --shared -o $(ELF_LIB) $(ELF_OTHER_LIBS) \ + $(LDFLAGS) -Wl,-h,$(ELF_SONAME) $(OBJS)) $(Q) $(MV) elfshared/$(ELF_LIB) . $(Q) $(RM) -f ../$(ELF_LIB) ../$(ELF_IMAGE).so ../$(ELF_SONAME) $(Q) (cd ..; $(LN) $(LINK_BUILD_FLAGS) \