【问题标题】:Linux Pam creates static library instead of shared libraryLinux Pam 创建静态库而不是共享库
【发布时间】:2014-01-28 00:51:03
【问题描述】:

我正在尝试通过以下方式为 android 交叉编译 Linux PAM

`#!/bin/sh
# Linux-PAM/build.sh

INSTALL_DIR="`pwd`/out"

export
PATH="android/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.6/bin:$PATH"
export CROSS_COMPILER="$PATH:android/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.6/bin"
export SYS_ROOT="android/prebuilts/ndk/current/platforms/android-9/arch-arm" 
export CC="arm-linux-androideabi-gcc --sysroot=$SYS_ROOT"
export LD="arm-linux-androideabi-ld"
export AR="arm-linux-androideabi-ar"
export RANLIB="arm-linux-androideabi-ranlib"
export STRIP="arm-linux-androideabi-strip"

mkdir -p $INSTALL_DIR
./configure --host=arm-eabi --build=x86_64 --enable-shared --prefix=$INSTALL_DIR LIBS="-lc -lgcc"

make
make install`

输出提供静态构建的库。我想要共享库。如果我为 linux 编译,它默认构建共享库。但对于 Android,它是静态构建的。 config.log 文件有以下内容

configure:3581: arm-linux-androideabi-gcc --sysroot=android/prebuilts/ndk/current/platforms/android-9/arch-arm -v >&5
Using built-in specs.
COLLECT_GCC=arm-linux-androideabi-gcc
COLLECT_LTO_WRAPPER=android/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.6/bin/../libexec/gcc/arm-linux-androideabi/4.6.x-google/lto-wrapper
Target: arm-linux-androideabi
Configured with: /tmp/android-8532/src/build/../gcc/gcc-4.6/configure --prefix=/usr/local --target=arm-linux-androideabi --host=x86_64-linux-gnu --build=x86_64-linux-gnu --with-gnu-as --with-gnu-ld --enable-languages=c,c++ --with-gmp=/tmp/android-8532/obj/temp-install --with-mpfr=/tmp/android-8532/obj/temp-install --with-mpc=/tmp/android-8532/obj/temp-install --without-ppl --without-cloog --disable-libssp --enable-threads --disable-nls --disable-libmudflap --disable-libgomp --disable-libstdc__-v3 --disable-sjlj-exceptions --disable-shared --disable-tls --disable-libitm --with-float=soft --with-fpu=vfp --with-arch=armv5te --enable-target-optspace --with-gcc-version=4.6 --with-binutils-version=2.21 --with-gmp-version=4.2.4 --with-mpfr-version=2.4.1 --with-gdb-version=7.3.x --with-arch=armv5te --with-sysroot=/tmp/android-8532/install/sysroot --with-prefix=/tmp/android-8532/install --with-gold-version=2.21 --enable-gold --program-transform-name='s&^&arm-linux-androideabi-&' --enable-gold=default


....

configure:10632: checking if libtool supports shared libraries
configure:10634: result: no
configure:10637: checking whether to build shared libraries
configure:10658: result: no

出了什么问题?

【问题讨论】:

    标签: linux gcc android-ndk autoconf pam


    【解决方案1】:

    我在从命令行交叉编译 Android 时遇到了类似的问题。 iOS 也很有趣。请参阅 Autoconf 邮件列表中的 How To Configure for Android?

    我认为host 不正确。试试:

    ./configure --build=`./config.guess` --host=arm ...
    

    ./configure --build=`./config.guess` --host=arm-linux-androideabi ...
    

    如果不是这样,您能否发布来自config.log 的完整结果(完全与共享对象测试相关,而不是整个文件)。

    很抱歉,我无法为您提供更多帮助。我正在我的 MacBook 上尝试 Linux-PAM-1.1.8 的交叉编译(它是为 Android 开发人员设置的),但这是我的结果:

    In file included from pam_modutil_private.h:14:0,
                     from pam_audit.c:12:
    ./include/security/pam_modutil.h:53:20: fatal error: shadow.h: No such file or directory
    compilation terminated.
    make[2]: *** [pam_audit.lo] Error 1
    make[1]: *** [all-recursive] Error 1
    make: *** [all] Error 2
    
    $ pwd
    /Users/jwalton/Linux-PAM-1.1.8
    $ find . -iname shadow.h
    $ 
    

    【讨论】:

    • 是的,我已经更正了我的设置中的编译错误。 shadow.h 在 android 中不存在。但是直到这一步,automake 和 libtool 已经决定它不会构建共享库。这也可以在您的 config.log 中看到。我相信,问题仅在于配置和构建脚本。
    【解决方案2】:

    我在大长日志字符串中注意到了这一点:

    Target: arm-linux-androideabi
    Configured with: /tmp/android-8532/src/build/../gcc/gcc-4.6/configure ...
    --disable-shared ...
    

    因此共享库被禁用,这意味着您不会构建它们。

    【讨论】:

    • 好收获。我的config.log 也有同样的情况。我想这应该转移给 Linux-PAM 人员,这样他们就可以调查这个问题。 (Autotools 对我来说是个谜)。
    • 是的,我观察到了这一点。但是使用相同的构建选项,我可以为其他包构建​​共享库。只有使用 automake 和 libtool 的 libpam 不会创建共享库。
    【解决方案3】:

    我进步了一点,发现can_build_shared标志被关闭了,因为它找不到host type = eabi的动态链接器

    配置:9299:检查动态链接器特征

    在配置脚本中检查如下

      { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5
    $as_echo_n "checking dynamic linker characteristics... " >&6; }
    
    
    if test "$GCC" = yes; then
      case $host_os in
    

    然后有一个类似 darwin、aix 的 host_os 列表...但没有 "host_os=eabi" 的替换案例

    这是根本原因。正在寻找解决方案..

    【讨论】:

      【解决方案4】:

      通过在配置脚本中的 dynamic_linker 和 deplibs_check_method 部分下添加对主机类型 = eabi 的支持来解决此问题。

      【讨论】:

      • 嗨@Sunil,你能解释一下你是如何解决这个问题的吗?在此之后,您是否成功交叉编译 PAM?
      • 在 libtool.m4 中进行了更改,以在 dynamic_linker eabi) library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' 2490 soname_spec='${libname}${release}${shared_ext}$major' 2491 shlibpath_var='$libdir' 2492 shlibpath_overrides_runpath=no 2493 dynamic_linker='eabi linker' 2494 ;; 部分下添加对 host type = eabi 的支持
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-30
      • 1970-01-01
      • 2021-03-18
      • 2017-12-27
      • 2011-05-17
      相关资源
      最近更新 更多