[Live-devel] [PATCH] Build real static libraries under Linux

Ben Hutchings ben at decadent.org.uk
Sun Sep 20 09:11:25 PDT 2009


This patch changes the Linux configs to build static libraries (archives
with symbol tables) using ar rather than building combined object files.
A real static library allows the final link to omit objects that are not
referenced, and can be referenced multiple times on the command line
without leading to multiple-definition errors.

It also fixes the library order in linker command lines for executables
to work with real static libraries.

This is only applied to the Linux configs because it relies on the fact
that GNU ar will automatically generate a symbol table.  On other
platforms a separate command 'ranlib' does that.

Ben.

diff --git a/config.armeb-uclibc b/config.armeb-uclibc
index 0fa5eca..2457f7b 100644
--- a/config.armeb-uclibc
+++ b/config.armeb-uclibc
@@ -11,8 +11,8 @@ OBJ =                  o
 LINK =                 $(CROSS_COMPILE)gcc -o
 LINK_OPTS =            -L.
 CONSOLE_LINK_OPTS =    $(LINK_OPTS)
-LIBRARY_LINK =         $(CROSS_COMPILE)ld -o
-LIBRARY_LINK_OPTS =    $(LINK_OPTS) -r -Bstatic
+LIBRARY_LINK =         $(CROSS_COMPILE)ar cr 
+LIBRARY_LINK_OPTS =    
 LIB_SUFFIX =                   a
 LIBS_FOR_CONSOLE_APPLICATION =
 LIBS_FOR_GUI_APPLICATION =
diff --git a/config.armlinux b/config.armlinux
index 62d44ee..ba4f761 100644
--- a/config.armlinux
+++ b/config.armlinux
@@ -10,8 +10,8 @@ OBJ =			o
 LINK =			$(CROSS_COMPILE)gcc -o
 LINK_OPTS =		-L.
 CONSOLE_LINK_OPTS =	$(LINK_OPTS)
-LIBRARY_LINK =		$(CROSS_COMPILE)ld -o
-LIBRARY_LINK_OPTS =	$(LINK_OPTS) -r -Bstatic
+LIBRARY_LINK =		$(CROSS_COMPILE)ar cr 
+LIBRARY_LINK_OPTS =	
 LIB_SUFFIX =			a
 LIBS_FOR_CONSOLE_APPLICATION =
 LIBS_FOR_GUI_APPLICATION =
diff --git a/config.bfin-linux-uclibc b/config.bfin-linux-uclibc
index 5dad85a..3342b7a 100644
--- a/config.bfin-linux-uclibc
+++ b/config.bfin-linux-uclibc
@@ -10,8 +10,8 @@ OBJ                = o
 LINK               = $(CROSS_COMPILER)g++ -o
 LINK_OPTS          = -L.
 CONSOLE_LINK_OPTS  = $(LINK_OPTS)
-LIBRARY_LINK       = $(CROSS_COMPILER)ld -o
-LIBRARY_LINK_OPTS  = $(LINK_OPTS) -r -Bstatic -m elf32bfinfd
+LIBRARY_LINK       = $(CROSS_COMPILER)ar cr 
+LIBRARY_LINK_OPTS  = 
 LIB_SUFFIX         = a
 LIBS_FOR_CONSOLE_APPLICATION =
 LIBS_FOR_GUI_APPLICATION =
diff --git a/config.bfin-uclinux b/config.bfin-uclinux
index c36135c..157572e 100644
--- a/config.bfin-uclinux
+++ b/config.bfin-uclinux
@@ -10,8 +10,8 @@ OBJ =            o
 LINK =            $(CROSS_COMPILER)g++ -Wl,-elf2flt -o
 LINK_OPTS =        -L.
 CONSOLE_LINK_OPTS =    $(LINK_OPTS)
-LIBRARY_LINK =        $(CROSS_COMPILER)ld -o
-LIBRARY_LINK_OPTS =    $(LINK_OPTS) -r -Bstatic
+LIBRARY_LINK =        $(CROSS_COMPILER)ar cr 
+LIBRARY_LINK_OPTS =    
 LIB_SUFFIX =            a
 LIBS_FOR_CONSOLE_APPLICATION =
 LIBS_FOR_GUI_APPLICATION =
diff --git a/config.linux b/config.linux
index e111780..5c7bc8f 100644
--- a/config.linux
+++ b/config.linux
@@ -9,8 +9,8 @@ OBJ =			o
 LINK =			c++ -o
 LINK_OPTS =		-L.
 CONSOLE_LINK_OPTS =	$(LINK_OPTS)
-LIBRARY_LINK =		ld -o
-LIBRARY_LINK_OPTS =	$(LINK_OPTS) -r -Bstatic
+LIBRARY_LINK =		ar cr 
+LIBRARY_LINK_OPTS =	
 LIB_SUFFIX =			a
 LIBS_FOR_CONSOLE_APPLICATION =
 LIBS_FOR_GUI_APPLICATION =
diff --git a/config.linux-gdb b/config.linux-gdb
index 4c64030..87387e5 100644
--- a/config.linux-gdb
+++ b/config.linux-gdb
@@ -9,8 +9,8 @@ OBJ =			o
 LINK =			c++ -o
 LINK_OPTS =		-L.
 CONSOLE_LINK_OPTS =	$(LINK_OPTS)
-LIBRARY_LINK =		ld -o
-LIBRARY_LINK_OPTS =	$(LINK_OPTS) -r -Bstatic
+LIBRARY_LINK =		ar cr 
+LIBRARY_LINK_OPTS =	
 LIB_SUFFIX =			a
 LIBS_FOR_CONSOLE_APPLICATION =
 LIBS_FOR_GUI_APPLICATION =
diff --git a/config.uClinux b/config.uClinux
index cd20d2e..1e0696b 100644
--- a/config.uClinux
+++ b/config.uClinux
@@ -12,8 +12,8 @@ OBJ =            o
 LINK =            $(CROSS_COMPILE)g++ -o
 LINK_OPTS =        -L. $(LDFLAGS)
 CONSOLE_LINK_OPTS =    $(LINK_OPTS)
-LIBRARY_LINK =        $(CROSS_COMPILE)ld -o
-LIBRARY_LINK_OPTS =    -L.  -r -Bstatic
+LIBRARY_LINK =        $(CROSS_COMPILE)ar cr 
+LIBRARY_LINK_OPTS =    
 LIB_SUFFIX =            a
 LIBS_FOR_CONSOLE_APPLICATION = $(CXXLIBS)
 LIBS_FOR_GUI_APPLICATION = $(LIBS_FOR_CONSOLE_APPLICATION)
diff --git a/mediaServer/Makefile.tail b/mediaServer/Makefile.tail
index 51b5b66..606b8ae 100644
--- a/mediaServer/Makefile.tail
+++ b/mediaServer/Makefile.tail
@@ -25,7 +25,7 @@ LIVEMEDIA_LIB = $(LIVEMEDIA_DIR)/libliveMedia.$(LIB_SUFFIX)
 GROUPSOCK_DIR = ../groupsock
 GROUPSOCK_LIB = $(GROUPSOCK_DIR)/libgroupsock.$(LIB_SUFFIX)
 LOCAL_LIBS =	$(LIVEMEDIA_LIB) $(GROUPSOCK_LIB) \
-		$(USAGE_ENVIRONMENT_LIB) $(BASIC_USAGE_ENVIRONMENT_LIB)
+		$(BASIC_USAGE_ENVIRONMENT_LIB) $(USAGE_ENVIRONMENT_LIB)
 LIBS =			$(LOCAL_LIBS) $(LIBS_FOR_CONSOLE_APPLICATION)
 
 live555MediaServer$(EXE):	$(MEDIA_SERVER_OBJS) $(LOCAL_LIBS)
diff --git a/testProgs/Makefile.tail b/testProgs/Makefile.tail
index e0028b9..589866f 100644
--- a/testProgs/Makefile.tail
+++ b/testProgs/Makefile.tail
@@ -60,7 +60,7 @@ LIVEMEDIA_LIB = $(LIVEMEDIA_DIR)/libliveMedia.$(LIB_SUFFIX)
 GROUPSOCK_DIR = ../groupsock
 GROUPSOCK_LIB = $(GROUPSOCK_DIR)/libgroupsock.$(LIB_SUFFIX)
 LOCAL_LIBS =	$(LIVEMEDIA_LIB) $(GROUPSOCK_LIB) \
-		$(USAGE_ENVIRONMENT_LIB) $(BASIC_USAGE_ENVIRONMENT_LIB)
+		$(BASIC_USAGE_ENVIRONMENT_LIB) $(USAGE_ENVIRONMENT_LIB)
 LIBS =			$(LOCAL_LIBS) $(LIBS_FOR_CONSOLE_APPLICATION)
 
 testMP3Streamer$(EXE):	$(MP3_STREAMER_OBJS) $(LOCAL_LIBS)
-- 
1.6.4.3


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 828 bytes
Desc: This is a digitally signed message part
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20090920/6cae1221/attachment.bin>


More information about the live-devel mailing list