undefined reference to `__android_log_print'

前端 未结 15 1949
不知归路
不知归路 2020-12-02 09:26

What is wrong with my make file?

Android.mk

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE    := foo
LOCAL_SRC_FILES := foo.c
LOCAL         


        
相关标签:
15条回答
  • 2020-12-02 09:56

    TO build with Android.bp, follow the below solution:

    In this -android_log_print is defined in NDK, so for this, there is already a library is available. Use "liblog" library using shared_libs tag, take reference of the below code:

    target: {
            android: {
                cppflags: [
                    "-g",
                    "-DUSE_LIBLOG",
                ],
                shared_libs: ["liblog"], // can use other dependency if required.
            },
            darwin: {
                enabled: false,
            },
        },  
    
    0 讨论(0)
  • 2020-12-02 10:00

    You need to add

    LOCAL_LDLIBS := -llog
    

    to Android.mk

    0 讨论(0)
  • 2020-12-02 10:04

    If you use Android Studio and gradle, it ignores Android.mk. Add this to your build.gradle file:

    android {
        defaultConfig {
            ndk {
                moduleName "your_module_name"
                ldLibs "log"
            }
        }
    }
    
    0 讨论(0)
  • 2020-12-02 10:04

    If you upgrade to Android Studio 2.1, above answers do not work, need use ldLibs.add() to load the lib as below:

    android.ndk {
        moduleName = "[the_module_name]"
        ldLibs.addAll(['android', 'log'])
    }
    
    0 讨论(0)
  • 2020-12-02 10:05

    In lieu with

    If using the new Gradle NDK integration in Android Studio 1.3, you need to add ldLibs = ["android", "log"] to your android.ndk options – Stephen Kaiser Sep 24 at 4:20

    use ldLibs.addAll(["android", "log"]) for the experimental plugin

    0 讨论(0)
  • 2020-12-02 10:06

    Add

    LOCAL_SHARED_LIBRARIES:= \
            libbinder                       \
            liblog                          \
    

    to Android.mk

    0 讨论(0)
提交回复
热议问题