ivanarh / libunwind-ndk

Patched libunwind from Android sources (https://android.googlesource.com/platform/external/libunwind/) to build with standard NDK toolchain (android-15).
MIT License
12 stars 9 forks source link

Build Error #3

Open deepakrokz opened 6 years ago

deepakrokz commented 6 years ago

Hi @ivanarh , I am trying to add libunwind-ndk in my project with the help of https://github.com/ivanarh/nativecrashes. Getting this error can your please help.

Build command failed. Error while executing process E:\Softwares\AndroidStudio\Sdk\cmake\3.6.4111459\bin\cmake.exe with arguments {-HD:\MyWorkspace\test\app\src\main\cpp -BD:\MyWorkspace\test\app.externalNativeBuild\cmake\debug\armeabi-v7a -GAndroid Gradle - Ninja -DANDROID_ABI=armeabi-v7a -DANDROID_NDK=E:\Softwares\AndroidStudio\Sdk\ndk-bundle -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=D:\MyWorkspace\test\app\build\intermediates\cmake\debug\obj\armeabi-v7a -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=E:\Softwares\AndroidStudio\Sdk\cmake\3.6.4111459\bin\ninja.exe -DCMAKE_TOOLCHAIN_FILE=E:\Softwares\AndroidStudio\Sdk\ndk-bundle\build\cmake\android.toolchain.cmake -DANDROID_PLATFORM=android-14 -DANDROID_PLATFORM=android-15 -DANDROID_TOOLCHAIN=clang -DANDROID_STL=gnustl_static -DANDROID_ARM_MODE=arm -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON} (include) CMakeLists.txt -- Check for working C compiler: E:/Softwares/AndroidStudio/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe -- Check for working C compiler: E:/Softwares/AndroidStudio/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: E:/Softwares/AndroidStudio/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe -- Check for working CXX compiler: E:/Softwares/AndroidStudio/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done CMake Error at CMakeLists.txt:7 (add_subdirectory): -- Configuring incomplete, errors occurred! See also "D:/MyWorkspace/test/app/.externalNativeBuild/cmake/debug/armeabi-v7a/CMakeFiles/CMakeOutput.log". Build command failed. Error while executing process E:\Softwares\AndroidStudio\Sdk\cmake\3.6.4111459\bin\cmake.exe with arguments {-HD:\MyWorkspace\test\app\src\main\cpp -BD:\MyWorkspace\test\app.externalNativeBuild\cmake\release\armeabi-v7a -GAndroid Gradle - Ninja -DANDROID_ABI=armeabi-v7a -DANDROID_NDK=E:\Softwares\AndroidStudio\Sdk\ndk-bundle -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=D:\MyWorkspace\test\app\build\intermediates\cmake\release\obj\armeabi-v7a -DCMAKE_BUILD_TYPE=Release -DCMAKE_MAKE_PROGRAM=E:\Softwares\AndroidStudio\Sdk\cmake\3.6.4111459\bin\ninja.exe -DCMAKE_TOOLCHAIN_FILE=E:\Softwares\AndroidStudio\Sdk\ndk-bundle\build\cmake\android.toolchain.cmake -DANDROID_PLATFORM=android-14 -DANDROID_PLATFORM=android-15 -DANDROID_TOOLCHAIN=clang -DANDROID_STL=gnustl_static -DANDROID_ARM_MODE=arm -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON} (include) CMakeLists.txt -- Check for working C compiler: E:/Softwares/AndroidStudio/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe -- Check for working C compiler: E:/Softwares/AndroidStudio/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: E:/Softwares/AndroidStudio/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe -- Check for working CXX compiler: E:/Softwares/AndroidStudio/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done CMake Error at CMakeLists.txt:7 (add_subdirectory): -- Configuring incomplete, errors occurred! See also "D:/MyWorkspace/test/app/.externalNativeBuild/cmake/release/armeabi-v7a/CMakeFiles/CMakeOutput.log".

Here is my build.gradle configuration for ndk: defaultConfig { applicationId = 'com.example.hellolibs' minSdkVersion 14 targetSdkVersion 25 versionCode = 1 versionName = '1.0' externalNativeBuild { cmake { arguments "-DANDROID_PLATFORM=android-15", '-DANDROID_TOOLCHAIN=clang', '-DANDROID_STL=gnustl_static', "-DANDROID_ARM_MODE=arm", "-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON" } } ndk { abiFilters "x86", "armeabi", "armeabi-v7a" } } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } sourceSets { main { // let gradle pack the shared library into apk jniLibs.srcDirs = ['../distribution/gperf/lib'] } } externalNativeBuild { cmake { path 'src/main/cpp/CMakeLists.txt' } }

and CMakeLists.txt is `cmake_minimum_required(VERSION 3.4.1)

libunwind start

set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -fno-optimize-sibling-calls -fno-inline") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fno-optimize-sibling-calls -fno-inline")

add_subdirectory(src/main/cpp/external/libunwind/cmake) include_directories(src/main/cpp/external/libunwind/include)

find_library(log-lib log)

libunwind end

set(distribution_DIR ${CMAKE_SOURCE_DIR}/../../../../distribution)

add_library(lib_gmath STATIC IMPORTED) set_target_properties(lib_gmath PROPERTIES IMPORTED_LOCATION ${distribution_DIR}/gmath/lib/${ANDROID_ABI}/libgmath.a)

add_library(lib_gperf SHARED IMPORTED) set_target_properties(lib_gperf PROPERTIES IMPORTED_LOCATION ${distribution_DIR}/gperf/lib/${ANDROID_ABI}/libgperf.so)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")

add_library(test1 SHARED test1.cpp Demo.cpp native-lib.c )

target_include_directories(test1 PRIVATE ${distribution_DIR}/gmath/include ${distribution_DIR}/gperf/include)

target_link_libraries(test1 ${log-lib} unwind android lib_gmath lib_gperf log) `

Please suggest, I am stuck from several days. Thanks in advance!

deepakrokz commented 6 years ago

Getting this, please check

CMake Error at CMakeLists.txt:7 (add_subdirectory):

ivanarh commented 6 years ago

Try git submodule update --init --recursive Libunwind requires lzma library which is added as a submodule, i suspect you didn't fetch it.

deepakrokz commented 6 years ago

I am adding complete source code of this https://github.com/ivanarh/libunwind-ndk/tree/58d2371c86789c2cc591be116348147bcca34cf1 in this location

src/main/cpp/external/libunwind/

why do I need to run this command when it's not synced with Github link, so not able to run the command

ivanarh commented 6 years ago

You should either clone libunwind-ndk repository as a submodule or manually clone https://android.googlesource.com/platform/external/lzma repository to lzma folder in libunwind-ndk root.

deepakrokz commented 6 years ago

I did the manual clone of Lzma and added in the root of libunwind-ndk root but still getting this

CMake Error at CMakeLists.txt:7 (add_subdirectory):

ivanarh commented 6 years ago

Please add CMAKE_VERBOSE_MAKEFILE argument to your build.gradle, it should be something like this:

android {
    ...
    defaultConfig {
       ...
        externalNativeBuild {
            cmake {
                arguments "-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON"
            }
        }

After that run build from console: ./gradlew assembleDebug

And attach a full build output.

deepakrokz commented 6 years ago

I tried as you suggested but no luck, earlier I was trying with this argument

arguments '-DANDROID_PLATFORM=android-15', '-DANDROID_ARM_MODE=arm', '-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON', '-DANDROID_TOOLCHAIN=clang', '-DANDROID_STL=gnustl_static'

deepakrokz commented 6 years ago

Hi @ivanarh ,

can you please help me out of this, please.

ivanarh commented 6 years ago

I can't help you without a full build log. If you can't build an app from console you can attach a following file:

D:/MyWorkspace/hello-libs/app/.externalNativeBuild/cmake/release/armeabi-v7a/CMakeFiles/CMakeOutput.log

I hope it would help.

deepakrokz commented 6 years ago

Thanks for your time and reply, CMakeOutput.log here is the file you are asking for:

deepakrokz commented 6 years ago

Hi @ivanarh , Have you found anything?