您的位置:首页 > 其它

glib交叉编译及常见问题(uclibc,arm)

2013-04-13 16:39 302 查看
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带来的问题

比如,编译gkeyfile.c:
gkeyfile.c: In function `g_key_file_get_locale_string':
gkeyfile.c:2190: error: syntax error before '!=' token

在glibintl.h中,bind_textdomain_codeset只是个空定义,没有返回值

#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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: