• 14
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191

Backtrace:

File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

I'm trying to configure Android.mk to cross compile native code to support different chipset namely armeabi, mips, and x86. I know I can configure Application.mk in the following way to compile the source code for different chip set:

APP_ABI := all

This will trigger Android-NDK's build script to compile the source code for all the chipsets. However, I want to dynamically tell Android.mk to look for different static library dependencies compiled with different chip set.

# Get the architecture info
ARCH := ????

include $(CLEAR_VARS)
LOCAL_MODULE:= mylib
LOCAL_SRC_FILES:= build/lib/libxxx_$(ARCH).a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
include $(PREBUILT_STATIC_LIBRARY)

Is this possible to do? If so, can anyone advice how to do so?

Update: I tried something like this in Application.mk:

 APP_ABI := armeabi armeabi-v7a mips x64

with Android.mk:

# Get the architecture info
ARCH := $(APP_ABI)

include $(CLEAR_VARS)
LOCAL_MODULE:= mylib
LOCAL_SRC_FILES:= build/lib/libxxx_$(ARCH).a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
include $(PREBUILT_STATIC_LIBRARY)

but it errors with the following:

 The LOCAL_SRC_FILES for a prebuilt static library should only contain one item

which makes sense. I want to pass APP_ABI := all in Application.mk and be able to dynamically reference it. Any ideas?

      • 1
    • If you look at ndk and other libs, they use defines such as #ifdef __arm__ but I am not sure where it's defined or standardized
      • 2
    • Hi , i want to do exactly the same thing. Can you give me example of Andorid.mk file and where to put it in the app??

Check TARGET_ARCH_ABI:

ifeq($(TARGET_ARCH_ABI), armeabi-v7a)
  # v7a-specific stuff
endif
  • 34
Reply Report
      • 1
    • You must set APP_ABI := all in Application.mk, otherwise ndk-build will only use the default armeabi architecture. For multiple architectures, NDK will iteratively call your Android.mk file - every time setting $(TARGET_ARCH_ABI) differently.
      • 1
    • $TARGET_ARCH_ABI simply returns whatever I set in APP_ABI. Is there any way I can pass either APP_ABI := armeabi armeabi-v7a mips x64 or APP_ABI := all?

There is TARGET_ARCH variable that holds the value of the current ABI being built. You can use it the following way:

ifeq ($(TARGET_ARCH),x86)
    LOCAL_CFLAGS   := $(COMMON_FLAGS_LIST)
else
    LOCAL_CFLAGS   := -mfpu=vfp -mfloat-abi=softfp $(COMMON_FLAGS_LIST)
endif

If you specify APP_ABI := armeabi-v7a armeabi mips x86 or APP_ABI := all in your Application.mk you will get each and every separate ABI value.

  • 29
Reply Report
    • Hello Sergey, thanks for the answer. It worked like a charm! I also appreciate how you gave me an example on how I can better use this as well. I was also getting fp warning when compiling but this also resolved that warning as well :)
      • 2
    • FYI, not sure if u intended your code as extra help but I tried anyway because I was curious :) LOCAL_CFLAGS := -mfpu=vfp -mfloat-abi=softfp. I observed that it errors while compiling mips architecture, it errored with the following:cc1plus: error: unrecognized command line option "-mfpu=vfp" cc1plus: error: unrecognized command line option "-mfloat-abi=softfp". This means the correct code snippet would be LOCAL_CFLAGS would be ifeq ($(TARGET_ARCH),arm) LOCAL_CFLAGS := -mfpu=vfp -mfloat-abi=softfp $(COMMON_FLAGS_LIST) else LOCAL_CFLAGS := $(COMMON_FLAGS_LIST). endif. Right?