在交叉编译用于android的util-linux库时出错

时间:2017-11-10 06:44:42

标签: c linux android-ndk

我正在使用arm-linux-androideabi交叉编译用于android的util-linux库。

我创建了工具链并执行了configure语句     ./configure --prefix = / opt / android --build = $ {BUILD} --host = arm-linux-androideabi --disable-rpath --without-util --without-ncursesw --without-ncurses - 没有锡箔

做完之后,我遇到了以下错误。

/u/CC/android-ndk-toolchain/sysroot/usr/include/fcntl.h:49:13: warning: redundant redeclaration of 'fcntl' [-Wredundant-decls]
In file included from libblkid/src/topology/sysfs.c:17:0:
/u/CC/android-ndk-toolchain/sysroot/usr/include/unistd.h:143:12: note: previous declaration of 'fcntl' was here
In file included from ./include/blkdev.h:11:0,
                 from ./libblkid/src/blkidP.h:34,
                 from libblkid/src/topology/topology.h:4,
                 from libblkid/src/topology/sysfs.c:21:
/u/CC/android-ndk-toolchain/sysroot/usr/include/sys/ioctl.h:39:12: warning: redundant redeclaration of 'ioctl' [-Wredundant-decls]
In file included from libblkid/src/topology/sysfs.c:17:0:
/u/CC/android-ndk-toolchain/sysroot/usr/include/unistd.h:144:12: note: previous declaration of 'ioctl' was here
  CCLD     libblkid.la
/usr/lib/gcc/arm-linux-androideabi/4.7.4/../../../../arm-linux-androideabi/bin/ld: error: libblkid/src/.libs/libblkid_la-config.o: multiple definition of 'l'
/usr/lib/gcc/arm-linux-androideabi/4.7.4/../../../../arm-linux-androideabi/bin/ld: libblkid/src/.libs/libblkid_la-cache.o: previous definition here
/usr/lib/gcc/arm-linux-androideabi/4.7.4/../../../../arm-linux-androideabi/bin/ld: error: libblkid/src/.libs/libblkid_la-evaluate.o: multiple definition of 'l'
/usr/lib/gcc/arm-linux-androideabi/4.7.4/../../../../arm-linux-androideabi/bin/ld: libblkid/src/.libs/libblkid_la-cache.o: previous definition here
/usr/lib/gcc/arm-linux-androideabi/4.7.4/../../../../arm-linux-androideabi/bin/ld: error: libblkid/src/.libs/libblkid_la-save.o: multiple definition of 'l'
/usr/lib/gcc/arm-linux-androideabi/4.7.4/../../../../arm-linux-androideabi/bin/ld: libblkid/src/.libs/libblkid_la-cache.o: previous definition here
/usr/lib/gcc/arm-linux-androideabi/4.7.4/../../../../arm-linux-androideabi/bin/ld: error: ./.libs/libcommon.a(libcommon_la-blkdev.o): multiple definition of 'l'
/usr/lib/gcc/arm-linux-androideabi/4.7.4/../../../../arm-linux-androideabi/bin/ld: libblkid/src/.libs/libblkid_la-cache.o: previous definition here
/usr/lib/gcc/arm-linux-androideabi/4.7.4/../../../../arm-linux-androideabi/bin/ld: error: ./.libs/libcommon.a(libcommon_la-env.o): multiple definition of 'l'
/usr/lib/gcc/arm-linux-androideabi/4.7.4/../../../../arm-linux-androideabi/bin/ld: libblkid/src/.libs/libblkid_la-cache.o: previous definition here
/usr/lib/gcc/arm-linux-androideabi/4.7.4/../../../../arm-linux-androideabi/bin/ld: error: ./.libs/libcommon.a(libcommon_la-pager.o): multiple definition of 'l'
/usr/lib/gcc/arm-linux-androideabi/4.7.4/../../../../arm-linux-androideabi/bin/ld: libblkid/src/.libs/libblkid_la-cache.o: previous definition here
/usr/lib/gcc/arm-linux-androideabi/4.7.4/../../../../arm-linux-androideabi/bin/ld: error: ./.libs/libcommon.a(libcommon_la-parse-date.o): multiple definition of 'l'
/usr/lib/gcc/arm-linux-androideabi/4.7.4/../../../../arm-linux-androideabi/bin/ld: libblkid/src/.libs/libblkid_la-cache.o: previous definition here
/usr/lib/gcc/arm-linux-androideabi/4.7.4/../../../../arm-linux-androideabi/bin/ld: error: ./.libs/libcommon.a(libcommon_la-path.o): multiple definition of 'l'
/usr/lib/gcc/arm-linux-androideabi/4.7.4/../../../../arm-linux-androideabi/bin/ld: libblkid/src/.libs/libblkid_la-cache.o: previous definition here
/usr/lib/gcc/arm-linux-androideabi/4.7.4/../../../../arm-linux-androideabi/bin/ld: error: ./.libs/libcommon.a(libcommon_la-randutils.o): multiple definition of 'l'
/usr/lib/gcc/arm-linux-androideabi/4.7.4/../../../../arm-linux-androideabi/bin/ld: libblkid/src/.libs/libblkid_la-cache.o: previous definition here
/usr/lib/gcc/arm-linux-androideabi/4.7.4/../../../../arm-linux-androideabi/bin/ld: error: ./.libs/libcommon.a(libcommon_la-strutils.o): multiple definition of 'l'
/usr/lib/gcc/arm-linux-androideabi/4.7.4/../../../../arm-linux-androideabi/bin/ld: libblkid/src/.libs/libblkid_la-cache.o: previous definition here
/usr/lib/gcc/arm-linux-androideabi/4.7.4/../../../../arm-linux-androideabi/bin/ld: error: ./.libs/libcommon.a(libcommon_la-timeutils.o): multiple definition of 'l'
/usr/lib/gcc/arm-linux-androideabi/4.7.4/../../../../arm-linux-androideabi/bin/ld: libblkid/src/.libs/libblkid_la-cache.o: previous definition here
/usr/lib/gcc/arm-linux-androideabi/4.7.4/../../../../arm-linux-androideabi/bin/ld: error: ./.libs/libcommon.a(libcommon_la-ttyutils.o): multiple definition of '_POSIX_VDISABLE'
/usr/lib/gcc/arm-linux-androideabi/4.7.4/../../../../arm-linux-androideabi/bin/ld: ./.libs/libcommon.a(libcommon_la-pager.o): previous definition here
/usr/lib/gcc/arm-linux-androideabi/4.7.4/../../../../arm-linux-androideabi/bin/ld: error: ./.libs/libcommon.a(libcommon_la-exec_shell.o): multiple definition of 'l'
/usr/lib/gcc/arm-linux-androideabi/4.7.4/../../../../arm-linux-androideabi/bin/ld: libblkid/src/.libs/libblkid_la-cache.o: previous definition here
/usr/lib/gcc/arm-linux-androideabi/4.7.4/../../../../arm-linux-androideabi/bin/ld: error: ./.libs/libcommon.a(libcommon_la-plymouth-ctrl.o): multiple definition of 'l'
/usr/lib/gcc/arm-linux-androideabi/4.7.4/../../../../arm-linux-androideabi/bin/ld: libblkid/src/.libs/libblkid_la-cache.o: previous definition here
/usr/lib/gcc/arm-linux-androideabi/4.7.4/../../../../arm-linux-androideabi/bin/ld: error: ./.libs/libcommon.a(libcommon_la-langinfo.o): multiple definition of 'l'
/usr/lib/gcc/arm-linux-androideabi/4.7.4/../../../../arm-linux-androideabi/bin/ld: libblkid/src/.libs/libblkid_la-cache.o: previous definition here
collect2: error: ld returned 1 exit status
Makefile:5414: recipe for target 'libblkid.la' failed
make[2]: *** [libblkid.la] Error 1
make[2]: Leaving directory '/u/CC/util-linux-2.31'
Makefile:11990: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/u/CC/util-linux-2.31'
Makefile:5002: recipe for target 'all' failed
make: *** [all] Error 2

请帮我解决此问题。 提前谢谢。

1 个答案:

答案 0 :(得分:0)

有关重新声明的第一个警告是由于NDK标头损坏。直到&#34;统一标题&#34;他们直接从fcntl()ioctl()盲目声明<fcntl.h><unistd.h>(可能还有更多内容),而不会检查它们是否已经宣布。统一标头以正确的方式执行,并且自NDK r14起可用,请参阅here

关于第二个问题 - 您可能会将名为l_POSIX_VDISABLE的事件定义为全局变量或函数。看起来像构建脚本中的一些问题。很高兴看到实际的编译器/链接器命令。