Android makefile for static executable generators

I am trying to create an executable file something like adbd in / sbin.

The executable I want to have is an iwlist with ARM format, and the type is static.

I added the folder to AndroidSourceCode / external and ran the "mm" command to compile

LOCAL_PATH := $(call my-dir) ifneq ($(TARGET_SIMULATOR),true) include $(CLEAR_VARS) LOCAL_MODULE := libiw LOCAL_MODULE_TAGS := eng LOCAL_SRC_FILES := iwlib.c LOCAL_C_INCLUDE += LOCAL_PATH LOCAL_PRELINK_MODULE := false include $(BUILD_SHARED_LIBRARY) #================================================ include $(CLEAR_VARS) LOCAL_FORCE_STATIC_EXECUTABLE := true LOCAL_MODULE_TAGS := eng LOCAL_SRC_FILES := iwlist.c LOCAL_SHARED_LIBRARIES := libiw LOCAL_MODULE := iwlist include $(BUILD_EXECUTABLE) #================================================ endif # !TARGET_SIMULATOR 

The above make file really works by creating an iwlist executable with

  iwlist: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), stripped 

However, I am looking for “statically linked” and I thought: “LOCAL_FORCE_STATIC_EXECUTABLE: = true” this line should help me make this executable statically.

Unfortunately, this is not the case.

I ask you if you know how to do this.

Thanks in advance.

+4
source share
1 answer

I have a similar problem, but I was not able to compile statically linked files using the Android toolchain. You can use another toolchain for this. I tried using toolchain from linaro and it works fine. You can download here: https://wiki.linaro.org/WorkingGroups/ToolChain

I downloaded version 4.7 by unzipping the file location in my home directory. Compiling is as simple as:

 ~/gcc-linaro-arm-linux-gnueabihf-2012.06-20120625_linux/bin/arm-linux-gnueabihf-gcc -static -s hello.c -o hello 

Of course, I recommend that you put the bin directory in your path.

This will create a statically linked file:

 # file hello hello: ELF 32-bit LSB executable, ARM, version 1 (SYSV), statically linked, for GNU/Linux 2.6.31, stripped 
+1
source

All Articles