Static libraries using glib-config



Hello,

I have a simple suggestion for the (much talented ;o) developers of glib.
(gtk+ developers may also be interested)

By default, both static and dynamic libraries are built during glib installation:
this is fine for me.

At work, we want to link statically an application against glib.

So I tried to use the elegant way to do that, that is to use "glib-config".

But with  "glib-config", there is no way to get the static libraries instead
of the dynamic libraries (option "--libs").

So I suggest the little patch attached to this post, that add an option "--staticlibs"
to "glib-config" in order to get something like "/usr/local/lib/libglib.a" instead of
"-L/usr/local/lib -lglib".

This problem had already been noticed back in 1998, but seemingly never addressed:
   http://mail.gnome.org/archives/gtk-list/1998-November/msg00701.html

Have a nice day.

--- glib-1.2.10.old/glib-config.in	Sat Oct 28 06:35:30 2000
+++ glib-1.2.10/glib-config.in	Thu Feb 14 10:27:41 2002
@@ -12,7 +12,7 @@
 	[--prefix[=DIR]]
 	[--exec-prefix[=DIR]]
 	[--version]
-	[--libs]
+	[--[static]libs]
 	[--cflags]
 Libraries:
 	glib
@@ -61,6 +61,9 @@
     --libs)
       echo_libs=yes
       ;;
+    --staticlibs)
+      echo_staticlibs=yes
+      ;;
     glib)
       lib_glib=yes
       ;;
@@ -105,4 +108,20 @@
 		libsa="$libsa @G_MODULE_LIBS@"
 	fi
 	echo -L libdir@ $libsp $libsa
+fi
+if test "$echo_staticlibs" = "yes"; then
+	libsp=""
+	libsa=""
+	if test "$lib_glib" = "yes"; then
+		libsp="@libdir@/libglib.a"
+	fi
+	if test "$lib_gthread" = "yes"; then
+		libsp="@libdir@/libgthread.a $libsp"
+		libsa="$libsa -lpthread"
+	fi
+	if test "$lib_gmodule" = "yes"; then
+		libsp="@libdir@/libgmodule.a $libsp"
+		libsa="$libsa @G_MODULE_LIBS@"
+	fi
+	echo $libsp $libsa
 fi


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]