Skip to content

AndroidStudio 'define inline' problem #6574

@T-Nosaka

Description

@T-Nosaka

Reproduction steps

Include libgit2 in CMake.

I need build in libgit2 by AndroidStudio.
But, below happened on compile error.
Need modify in-line code.
/src/libgit2/util/git2_util.h LINE 96

The error content is "error: unknown type name 'inline'".

Inline seems to be affected when "# include <arpa/inet.h>" in Android compilation environment.
Therefore, it works fine by modifying as follows.

#ifdef ANDROID
#define inline
#endif
#include <arpa/inet.h>

makebuild.sh

#!/bin/bash

export LIBGIT2=libgit2-1.6.4

#TOOLCHAIN
export NDKVER=25.1.8937393

PLATFORMNAME=`uname -s`
if [ $PLATFORMNAME = "Darwin" ]; then
export ANDROID_SDK=~/Library/Android/Sdk
LLVMPLATFORM="darwin-x86_64"
else
export ANDROID_SDK=~/Android/Sdk
LLVMPLATFORM="linux-x86_64"
fi
export NDK=${ANDROID_SDK}/ndk/${NDKVER}
export TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/${LLVMPLATFORM}
export CMAKE=${ANDROID_SDK}/cmake/3.22.1/bin/cmake
export OUTPUT_DIR=`pwd`/output
export OPENSSL_DIR=../openssl/output
export LIBSSH2_DIR=../libssh2/output
export MAKE=${NDK}/prebuilt/${LLVMPLATFORM}/bin/make

#API
export API_LEVEL=26

make_android() {
  NDKARCH=$1

  ${CMAKE}  \
  -H${LIBGIT2} \
  -Bmakegenerate/${NDKARCH} \
  -DOPENSSL_INCLUDE_DIR=${OPENSSL_DIR}/${NDKARCH} \
  -DOPENSSL_SSL_LIBRARY=${OPENSSL_DIR}/${NDKARCH}/libssl.a \
  -DOPENSSL_CRYPTO_LIBRARY=${OPENSSL_DIR}/${NDKARCH}/libcrypto.a \
  -DLIBSSH2_LIBRARY=${LIBSSH2_DIR}/${NDKARCH} \
  -DLIBSSH2_INCLUDE_DIR=${LIBSSH2_DIR}/${NDKARCH} \
  -DBUILD_EXAMPLES=OFF \
  -DBUILD_TESTS=OFF \
  -DBUILD_SHARED_LIBS=OFF \
  -DBUILD_CLI=OFF \
  -DUSE_SSH=ON \
  -DSONAME=OFF \
  -DLINT=OFF \
  -DANDROID_ABI=${NDKARCH} \
  -DANDROID_NATIVE_API_LEVEL=${API_LEVEL} \
  -DANDROID_NDK=${NDK} \
  -DCMAKE_TOOLCHAIN_FILE=${NDK}/build/cmake/android.toolchain.cmake \
  -DCMAKE_VERBOSE_MAKEFILE=TRUE \
  -DCMAKE_BUILD_TYPE=Release \
  -DCMAKE_MAKE_PROGRAM=${MAKE}

  cd makegenerate/${NDKARCH}
  ${MAKE}
  mkdir ${OUTPUT_DIR}/${NDKARCH}
  mv liblibgit2package.a ${OUTPUT_DIR}/${NDKARCH}/libgit2.a
  cd ../..
}

#Rebuild
rm -rf makegenerate
rm -rf output/*

cp -rp ${LIBGIT2}/include output/include

#ABI x86_64
make_android x86_64

#ABI armv7a
make_android armeabi-v7a

#ABI aarch64
make_android arm64-v8a

#ABI x86
make_android x86

Expected behavior

compile error.

Actual behavior

compile error.

Version of libgit2 (release number or SHA1)

2-1.6.4

Operating system(s) tested

Ubuntu21.10

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions