【问题标题】:ARM Cross Compile GLib 2.33.10, linker errorARM 交叉编译 GLib 2.33.10,链接器错误
【发布时间】:2012-08-31 15:07:42
【问题描述】:

我是新手,我正在研究 Raspberry Pi。我对 GLIB 2.33.10 交叉编译有疑问。 我已经从站点和所有依赖项(zlib、ffi)下载了源代码;已经为 ARM 构建了依赖项(在 Raspberry 上测试)。我目前正在使用 arm-bcm2708hardfp-linux-gnueabi 工具链。

我的配置命令行如下:

$ ZLIB_CFLAGS=-I/home/myuser/cross_lib/include/libzlib \
ZLIB_LIBS="-L/home/myuser/cross_lib/lib/libzlib/raspberry -lz" \
LDFLAGS="-L/home/myuser/cross_lib/libffi/lib -lffi -L/home/myuser/cross_lib/lib/libzlib/raspberry -lz" 
LIBFFI_CFLAGS=-I/home/myuser/cross_lib/libffi/lib/libffi-3.0.11/include \
LIBFFI_LIBS="-L/home/myuser/cross_lib/libffi/lib -lffi" \
./configure --host=arm-bcm2708hardfp-linux-gnueabi glib_cv_stack_grows=yes \
glib_cv_uscore=yes ac_cv_func_posix_getpwuid_r=no \
ac_cv_func_posix_getgrgid_r=no --with-libiconv=no --without-pcre \
--enable-gtk-doc-html=no --enable-xattr=no --prefix=/home/cross_lib/glib23

如您所见,我已禁用 iconv 和 pcre(这只是一个测试版本);配置脚本没问题(似乎没问题...)。在开始构建过程时,它会持续一段时间(编译大量代码)然后卡在链接阶段:

/opt/tools/arm-bcm2708/arm-bcm2708hardfp-linux-gnueabi/bin/../lib/gcc/arm-bcm2708hardfp-linux gnueabi/4.7.1/../../../../arm-bcm2708hardfp-linux-gnueabi/bin/ld: warning: libgthread-2.0.so.0, needed by ../gobject/.libs/libgobject-2.0.so, not found (try using -rpath or -rpath-link)
/opt/tools/arm-bcm2708/arm-bcm2708hardfp-linux-gnueabi/bin/../lib/gcc/arm-bcm2708hardfp-linux-gnueabi/4.7.1/../../../../arm-bcm2708hardfp-linux-gnueabi/bin/ld: warning: libgmodule-2.0.so.0, needed by ./.libs/libgio-2.0.so, not found (try using -rpath or -rpath-link)
./.libs/libgio-2.0.so: undefined reference to `g_module_close'
./.libs/libgio-2.0.so: undefined reference to `g_module_symbol'
./.libs/libgio-2.0.so: undefined reference to `g_module_supported'
./.libs/libgio-2.0.so: undefined reference to `g_module_open'
./.libs/libgio-2.0.so: undefined reference to `g_module_error'
collect2: error: ld returned 1 exit status
make[4]: *** [glib-compile-resources] Errore 1
make[4]: uscita dalla directory "/home/myuser/cross_lib/source/glib-2.33.10/gio"
make[3]: *** [all-recursive] Errore 1
make[3]: uscita dalla directory "/home/myuser/cross_lib/source/glib-2.33.10/gio"
make[2]: *** [all] Errore 2
make[2]: uscita dalla directory "/home/myuser/cross_lib/source/glib-2.33.10/gio"
make[1]: *** [all-recursive] Errore 1
make[1]: uscita dalla directory "/home/myuser/cross_lib/source/glib-2.33.10"
make: *** [all] Errore 2

这对我来说似乎是一个奇怪的错误,它找不到自己的库……但我不是专家……有人可以帮助我吗?谢谢你的建议,原谅我的英语不好

【问题讨论】:

  • 看起来包是用 --libs gmodule--xx 构建的,gmodule 通常带有 glib 确保它已安装并且是最新的。
  • 感谢您的回答!我没有设置 --libs 标签,现在我会调查...再次感谢您的好意:)
  • 抱歉..我找不到解决方案...还有其他建议吗?

标签: c linux arm cross-compiling glib


【解决方案1】:

只需在最后的 LDFLAGS 中添加-lgmodule-2.0

【讨论】:

    【解决方案2】:

    这对我来说适用于 glib 2.36.4:

    $ make LDFLAGS="-rpath $PWD/gmodule/.libs"

    【讨论】:

    • 这对我帮助很大。这是我用来编译的字符串 glib_cv_stack_grows=no glib_cv_uscore=no ac_cv_func_posix_getpwuid_r=no ac_cv_func_posix_getgrgid_r=no CFLAGS="-I/home/develop/Code/gettext-0.20.1/gettext-runtime/intl -L/home/develop/代码/gettext-0.20.1/gettext-runtime/intl/.libs" CC=arm-hisiv300-linux-gcc PKG_CONFIG_PATH=../pkg_config_path ./configure --host=arm-linux-gnueabi --enable-libmount=没有 --enable-static --with-pcre=internal
    【解决方案3】:

    以 Anon 的回答为基础,这是我的 DOckerfile 中的部分。诀窍是制造,让它失败,然后用标志再次制造:

    RUN printf "glib_cv_stack_grows=no\nglib_cv_uscore=no\n" > mips.cache
    RUN ZLIB_CFLAGS="-I${PREFIX}/include" \
        ZLIB_LIBS="-L${PREFIX}/lib/ -lz" \
        LIBFFI_CFLAGS="-I${PREFIX}/include/" \
        LIBFFI_LIBS="-L${PREFIX}/lib/ -lffi" \
        LD_LIBRARY_PATH="$PWD/gmodule/.libs -lgmodule-2.0" \
        LD=mips-linux-gnu-ld \
        AR=mips-linux-gnu-ar \
        ./autogen.sh --host=mips-linux-gnu --prefix=$PREFIX \
        --disable-man --disable-libmount --disable-largefile --disable-fam \
        --disable-xattr --disable-libelf --with-pcre=internal --disable-static \
        --cache-file=mips.cache
    RUN make -j 8; exit 0 && \
        make LDFLAGS="-rpath $PWD/gmodule/.libs" -j 8 && \
        make install
    

    【讨论】:

      猜你喜欢
      • 2021-02-26
      • 2016-12-04
      • 2020-12-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-10
      • 1970-01-01
      相关资源
      最近更新 更多