尝试为Android编译openssh

时间:2017-09-06 10:30:48

标签: android makefile android-ndk cross-compiling

目前我正在尝试交叉编译openssh。我已经编译过openssl,但是,我正在为openssh遇到麻烦。

这是构建openSSH的脚本的一部分:

export SYSROOT="$NDK_ROOT/platforms/$TARGET/arch-arm"
export CPPFLAGS="-I$NDK_ROOT/platforms/$TARGET/arch-arm/usr/include --sysroot=$SYSROOT"
export CC=$($NDK_ROOT/ndk-which gcc)
export LD=$($NDK_ROOT/ndk-which ld)
export CPP=$($NDK_ROOT/ndk-which cpp)
export CXX=$($NDK_ROOT/ndk-which g++)
export AS=$($NDK_ROOT/ndk-which as)
export AR=$($NDK_ROOT/ndk-which ar)
export RANLIB=$($NDK_ROOT/ndk-which ranlib)

export LIBS="-lssl -lcrypto -lz -ldl"
export LDFLAGS="-L$SCRIPTPATH/obj/local/armeabi"
./configure --host=arm-linux-androideabi --target=arm-linux-androideabi \
            --prefix=/data/local/tmp \
        --exec-prefix=/data/local/tmp \
            --with-ssl-dir=$SSLPATH \
            --disable-utmp \
            --disable-wtmp \
            --disable-utmpx \
            --disable-syslog \
            --without-shadow \
            --with-md5-passwords

$NDK_ROOT/ndk-build -j$JOBS -C $SCRIPTPATH openssh

lib的makefile:

SSHL_COMMON_CFLAGS := 
SSHL_COMMON_CFLAGS += \
  -DHAVE_CONFIG_H -DHAVE_MBLEN -DHAVE_ENDGRENT -DHAVE_LLABS -DHAVE_ARC4RANDOM_STIR -DHAVE_GETPAGESIZE
SSHL_CSOURCES := ssh_api.c \
    ssherr.c \
    sshbuf.c \
    sshkey.c \
    sshbuf-getput-basic.c \
    sshbuf-misc.c \
    sshbuf-getput-crypto.c \
    krl.c \
    bitmap.c \
        authfd.c authfile.c bufaux.c bufbn.c bufec.c buffer.c \
    canohost.c channels.c cipher.c cipher-aes.c cipher-aesctr.c \
    cipher-ctr.c cleanup.c \
    compat.c crc32.c fatal.c hostfile.c \
    log.c match.c moduli.c nchan.c packet.c opacket.c \
    readpass.c ttymodes.c xmalloc.c addrmatch.c \
    atomicio.c key.c dispatch.c mac.c uidswap.c uuencode.c misc.c utf8.c \
    monitor_fdpass.c rijndael.c ssh-dss.c ssh-ecdsa.c ssh-rsa.c dh.c \
    msg.c progressmeter.c dns.c entropy.c gss-genr.c umac.c  \
    ssh-pkcs11.c smult_curve25519_ref.c \
    poly1305.c chacha.c cipher-chachapoly.c \
    ssh-ed25519.c digest-openssl.c digest-libc.c hmac.c \
    sc25519.c ge25519.c fe25519.c ed25519.c verify.c hash.c blocks.c \
    kex.c kexdh.c kexgex.c kexecdh.c kexc25519.c \
    kexdhc.c kexgexc.c kexecdhc.c kexc25519c.c \
    kexdhs.c kexgexs.c kexecdhs.c kexc25519s.c \
    platform-pledge.c platform-tracing.c platform-misc.c 
SSHL_LOCAL_SRC_FILES := $(addprefix ../../openssh-portable/,$(SSHL_CSOURCES))
SSHL_LOCAL_C_INCLUDES += \
  $(LOCAL_PATH)/../../openssh-portable \
  $(LOCAL_PATH)/../../openssh-portable/openbsd-compat \
  $(NDK_PATH)/platforms/$(TARGET_PLATFORM)/arch-arm/usr/include \
  $(LOCAL_PATH)/../../openssl/include

我添加了之前的CFLAGS,因为我有扩展宏错误。我不确定他们!

android makefile的一部分:

#openssh
include $(LOCAL_PATH)/openssh.mk

#Static libssh
include $(CLEAR_VARS)
LOCAL_MODULE := openssh
LOCAL_SRC_FILES := $(SSL_LOCAL_SRC_FILES) $(CRYPTO_LOCAL_SRC_FILES) $(SSHL_LOCAL_SRC_FILES)
LOCAL_C_INCLUDES := $(SSL_LOCAL_C_INCLUDES) $(CRYPTO_LOCAL_C_INCLUDES) $(SSHL_LOCAL_C_INCLUDES)
LOCAL_CPPFLAGS += -std=c++11
LOCAL_CFLAGS += $(SSHL_COMMON_CFLAGS)
include $(BUILD_STATIC_LIBRARY)

我能够构建一个静态libssh.a,但是我无法为ssh程序创建可执行文件我遇到了错误:

bsd-statvfs.c:32:21: error: dereferencing pointer to incomplete type
  to->f_frsize = from->f_bsize; /* no exact equivalent */

有人已经为Android编译了openssh,这有用吗?

0 个答案:

没有答案