View Issue Details

IDProjectCategoryView StatusLast Update
0006693libmicrohttpdbuild systempublic2024-02-11 11:46
Reporternmm Assigned ToChristian Grothoff  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
OSandroid 
Product Version0.9.71 
Target Version0.9.72Fixed in Version0.9.72 
Summary0006693: unable to cross-compile for android due to MHD_NONNULL
DescriptionI'm trying to cross-compile for android (archs armeabi-v7a, arm64-v8a, x86, x86_64 and ABI 16), using NDK 22.0.7026061 and the included clang (11.0.5).
My host is x86_64 linux.
I created Application.mk and Android.mk but get theses errors when running ndk-build:

src/include/microhttpd2.h:1494:1: error: expected function body after function declarator
MHD_NONNULL (1);
^
/path/to/src/include/microhttpd2.h:286:26: note: expanded from macro 'MHD_NONNULL'
#define MHD_NONNULL(...) __THROW __nonnull ((__VA_ARGS__))

I've tried following steps[1] to cross-compile for, e.g., armeabi-v7a, but my config output always says "Cross-compiling: no".
Also, running
./configure --target=arm-linux-androideabi --host=arm-linux-androideabi --disable-doc --disable-examples
make
results in:
$ file src/microhttpd/.libs/libmicrohttpd.so
src/microhttpd/.libs/libmicrohttpd.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=aac0a89534cbd27bf4c33c4b7b98ed7165bb4380, not stripped
and not a 32bit ARM as i'd expect (perhaps i passed wrong parameters).

I've seen this[2] bug but it seems to be stale.

I've also noticed that in src/include/microhttpd2.h:286 the comment above reads "Todo: port to non-gcc platforms."
Does this mean it's not usable with clang yet?

[1] https://libmicrohttpd.gnu.narkive.com/QVMVGEL0/how-to-compile-mhd-for-armv7
[2] https://bugs.gnunet.org/view.php?id=4913
Steps To Reproducegit clone https://git.gnunet.org/libmicrohttpd.git
autoreconf -fi
./configure --target=arm-linux-androideabi --host=arm-linux-androideabi --disable-doc --disable-examples
ndk-build NDK_PROJECT_PATH="$PWD" NDK_APPLICATION_MK="$PWD/Application.mk" V=1
Tagsandroid, clang
Attached Files
Android.mk (1,254 bytes)   
LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

    LOCAL_MODULE := mhd

    APP_SUBDIRS := $(LOCAL_PATH)/src/include $(LOCAL_PATH)/src/lib $(LOCAL_PATH)/src/microhttpd

    LOCAL_C_INCLUDES := $(LOCAL_PATH) $(APP_SUBDIRS)
    LOCAL_CFLAGS := -Os

    LOCAL_CPP_EXTENSION := .cpp

    LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/src/lib/*.c) 
    LOCAL_SRC_FILES += $(wildcard $(LOCAL_PATH)/src/microhttpd/*.c)

    LOCAL_SHARED_LIBRARIES :=
    LOCAL_STATIC_LIBRARIES :=

    ifeq ($(TARGET_ARCH_ABI),x86)
        CLANG_TARGET  := -target i386-unknown-linux-android
    endif
    ifeq ($(TARGET_ARCH_ABI),x86_64)
        CLANG_TARGET  := -target x86_64-unknown-linux-android
    endif
    ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
        CLANG_TARGET  := -target armv7a-unknown-linux-android
    endif
    ifeq ($(TARGET_ARCH_ABI), arm64-v8a)
        CLANG_TARGET  := -target arm64v8a-unknown-linux-android
    endif
    DEFINES   := -D_DEF_RGBSTRUCT_ -DANDROID -D_ANDROID -D_ANDROID_ -D__ANDROID__ -D__DEBUG__ -DDEBUG_SAFE
    ALL_FLAGS := $(CLANG_TARGET) $(ALL_FLAGS) -v -w -Wno-gnu-array-member-paren-init -fpermissive -g -Wall $(DEFINES)

    LOCAL_CFLAGS += $(INCLUDES) -Wno-return-type $(ALL_FLAGS) -nostdinc++

include $(BUILD_SHARED_LIBRARY)

Android.mk (1,254 bytes)   
Application.mk (772 bytes)   
APP_OPTIM := debug

# see https://developer.android.com/ndk/guides/abis
# APP_ABI := armeabi-v7a arm64-v8a x86 x86_64 all
  APP_ABI := armeabi-v7a

# APP_STL := system, c++_shared, c++_static
# APP_STL := stlport_static no longer supported (in 22.0.6917172)
# APP_STL := gnustl_static no longer supported (in 22.0.6917172)
  APP_STL := c++_shared

# see:
# https://en.wikipedia.org/wiki/Android_version_history#Overview
# https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels
APP_PLATFORM := android-16 # Jelly Bean, android v4.1 - 4.3.1, rel July 9 2012

APP_PROJECT_PATH := $(call my-dir)
NDK_PROJECT_PATH := $(APP_PROJECT_PATH)

APP_BUILD_SCRIPT := $(APP_PROJECT_PATH)/Android.mk

APP_CPPFLAGS := -frtti -fexceptions

APP_MODULES := mhd

Application.mk (772 bytes)   

Activities

Christian Grothoff

2021-01-30 12:54

manager   ~0017456

b5bf6ccf..29683291 should fix the specific build issue reported.

Christian Grothoff

2021-09-02 17:54

manager   ~0018165

Fix committed to master branch.

Related Changesets

libmicrohttpd: master 29683291

2021-01-30 13:51

Christian Grothoff


Details Diff
fix 0006693: get src/lib/ to build with clang Affected Issues
0006693
mod - src/include/microhttpd2.h Diff File
mod - src/lib/daemon_get_timeout.c Diff File
mod - src/lib/daemon_select.c Diff File

Issue History

Date Modified Username Field Change
2021-01-12 19:09 nmm New Issue
2021-01-12 19:09 nmm Tag Attached: android
2021-01-12 19:09 nmm Tag Attached: clang
2021-01-12 19:09 nmm Tag Attached: ndk
2021-01-12 19:09 nmm File Added: Android.mk
2021-01-12 19:09 nmm File Added: Application.mk
2021-01-30 00:09 Christian Grothoff Assigned To => Christian Grothoff
2021-01-30 00:09 Christian Grothoff Status new => assigned
2021-01-30 12:54 Christian Grothoff Note Added: 0017456
2021-01-30 12:59 Christian Grothoff Status assigned => resolved
2021-01-30 12:59 Christian Grothoff Resolution open => fixed
2021-01-30 12:59 Christian Grothoff Fixed in Version => 0.9.72
2021-01-30 12:59 Christian Grothoff Target Version => 0.9.72
2021-01-30 12:59 Christian Grothoff Description Updated
2021-01-30 12:59 Christian Grothoff Steps to Reproduce Updated
2021-04-27 23:09 Christian Grothoff Status resolved => closed
2021-09-02 17:54 Christian Grothoff Changeset attached => libmicrohttpd master 29683291
2021-09-02 17:54 Christian Grothoff Note Added: 0018165
2024-02-11 11:46 Christian Grothoff Tag Detached: ndk