undefined reference to `__android_log_print'

前端 未结 15 2061
不知归路
不知归路 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条回答
  •  Happy的楠姐
    2020-12-02 10:22

    In case the project you are working on has the following characteristics that differ from other 'standard' answers:

    • Not using Android Studio
    • Not using gradle and the integrated CMake
    • No Android.mk or Application.mk used at all for build
    • Using CMake and the toolchain directly (maybe your project is Qt based and without using QtCreator neither)

    The following target_link_libraries usage makes it:

        find_library(ANDROID_LOG_LIB log)
        target_link_libraries(${TARGET_NAME} ${ANDROID_LOG_LIB})
    

    Being TARGET_NAMEthe name of the target to build (having set it up before with add_library or add_executable).

    find_library is equally important as well as setting up the toolchain properly (use the toolchain provided by Android SDK at ANDROID_SDK_HOME/cmake//android.toolchain.cmake so it sets up CMAKE_SYSROOTwhich is used by find_ commands).

提交回复
热议问题