gentoo有使用uclibc編譯glib2.6.2的補丁文件,雖然有些老
http://dev.gentoo.org/~solar/embedded/local/local/dev-libs/glib-uclibc/
關於configure配置程序的補丁,glib-2.4.6-config.path的內容:
--- configure.in.orig 2004-11-07 22:12:27.000000000 +0000
+++ configure.in 2004-11-07 22:11:58.000000000 +0000
@@ -373,7 +373,7 @@
esac
if test "x$found_iconv" = "xno" ; then
- AC_MSG_ERROR([*** No iconv() implementation found in C library or libiconv])
+ AC_MSG_RESULT([*** No iconv() implementation found in C library or libiconv. Using stubs])
fi
dnl
@@ -384,7 +384,7 @@
GLIB_GNU_GETTEXT
if test "$gt_cv_have_gettext" != "yes" ; then
- AC_MSG_ERROR([
+ AC_MSG_RESULT([*** For some unknown reason somebody thinks ***
*** You must have either have gettext support in your C library, or use the
*** GNU gettext library. (http://www.gnu.org/software/gettext/gettext.html
])
主要就是將原來出錯後的退出處理改爲消息顯示而不退出,在目前的glib版本(2.6.34),
跟AS_MSG_ERROR對應的函數是as_fn_error, 後面那個AC_MSG_RESULT大可以改爲簡單的echo來處理。
關於libiconv庫相關文件的補丁,glib-2.4.6-no_iconv.patch
--- glib/gconvert.c.mps Tue Sep 21 21:19:41 2004
+++ glib/gconvert.c Tue Sep 21 21:18:01 2004
@@ -22,7 +22,9 @@
#include "config.h"
+#ifdef HAVE_ICONV_H
#include <iconv.h>
+#endif
#include <errno.h>
#include <stdio.h>
#include <string.h>
@@ -49,6 +49,24 @@
#error GNU libiconv not in use but included iconv.h is from libiconv
#endif
+#ifndef HAVE_ICONV_H
+typedef void *iconv_t;
+
+static iconv_t iconv_open(const char *tocode, const char *fromcode)
+{
+ return (iconv_t)(-1);
+}
+
+static int iconv_close(iconv_t cd)
+{
+ free(cd);
+
+ return 0;
+}
+
+static size_t iconv() {return 0;}
+#endif
+
GQuark
g_convert_error_quark (void)
{
由於年代久遠,這些patch文件不能直接拿來使用,但對比後手動更改即可。
運行配置腳本:
./configure --with-libiconv=no --enable-gcov=no --host=arm-xxx --cache-file=arm-configure.cache
其中的--host參數指定你要使用的交叉編譯器的前綴(比如文中的arm-xxx,它補成arm-xxx-gcc)
--cache-file參數指定配置信息緩存文件(配置腳本會從中讀取,並會寫入參數)
常見錯誤:
1、“configure: error: cannot run test program while cross compiling”
很多檢測選項都會生成這條消息,比如:
checking for growing stack pointer... configure: error: in `/mnt/openlib/glib2.0-2.34.1':
這時候可以打開configure腳本文件,查找“for growing stack pointer”,
可以定位具體的出錯地點,按照開頭提到的修改configure的方法將其出錯信息屏蔽即可。
如果需要指定參數,可以手動將要檢測的變量值追加到參數中附帶的cache文件,比如這條錯誤信息可以:
echo "glib_cv_stack_grows=${glib_cv_stack_grows=no}" >>arm-configure.cache
在./configure時在命令行參數指定也可以:
./configure xxxxxx glib_cv_stack_grows=no
2、libintl.h的包含錯誤
編譯glib(不包含gobject、gthread、gio==)時起碼會報錯找不到這個頭文件,比如在ggettext.c中
可以按如下方式修改:
#ifdef ENABLE_NLS
#include <libintl.h>
#else
#include "glibintl.h"
#endif
其中的glibintl.h是對libintl.h的一個替換方案
3、glibintl.h帶來的問題
#define bind_textdomain_codeset(Domain,Codeset)
參考修改方式如下
#ifdef HAVE_BIND_TEXTDOMAIN_CODESET
codeset_set = bind_textdomain_codeset (key_file->gettext_domain, "UTF-8") != NULL;
#else
codeset_set = FALSE;
#endif
附:
./configure --with-libiconv=no --enable-gcov=no --host=arm-xxx-linux
--cache-file=xx.cache
--enable-static --disable-dependency-tracking glib_cv_stack_grows=no ac_cv_func_posix_getpwuid_r=yes ac_cv_func_posix_getgrgid_r=yes ac_cv_lib_rt_clock_gettime=no glib_cv_monotonic_clock=yes