Команда сборки не удалась. Ошибка при выполнении процесса - PullRequest
0 голосов
/ 31 октября 2018

Я включаю boost, cpprest и openssl в свой код, но это дает мне ошибки, такие как follow в android studio с использованием ndk Я дал все пути к каталогу и добавить в программу Он успешно собирается, но при запуске выдает следующие ошибки

Build command failed.
Error while executing process C:\Users\Dell\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\cmake.exe with arguments {--build D:\Android studio project\CppAddLibrary\app\.externalNativeBuild\cmake\debug\armeabi-v7a --target native-lib}
ninja: error: '/armeabi-v7a/libboost_system.so', needed by '../../../../build/intermediates/cmake/debug/obj/armeabi-v7a/libnative-lib.so', missing and no known rule to make it

мой CMakeList.txt равен

cmake_minimum_required(VERSION 3.4.1)
add_library(native-lib SHARED src/main/cpp/native-lib.cpp)

#---------------boost--------------------------
add_library (boost_system SHARED IMPORTED)

set_target_properties( boost_system PROPERTIES IMPORTED_LOCATION
        ${-DMY_BOOST_LIBS_DIR}/${ANDROID_ABI}/libboost_system.so
        )
#--------------boost_crono---------------------------
add_library( boost_chrono SHARED IMPORTED)

set_target_properties(boost_chrono PROPERTIES IMPORTED_LOCATION
        ${DMY_BOOST_LIBS_DIR}/${ANDROID_ABI}/libboost_chrono.so
        )
#----------openssl-------------------------------
add_library(ssl SHARED IMPORTED)

set_target_properties(ssl PROPERTIES IMPORTED_LOCATION
        ${DMY_OPENSSL_LIBS_DIR}/${ANDROID_ABI}/libssl.a
        )
 #--------------cpprest---------------------------
add_library( cpprestsdk SHARED IMPORTED)

set_target_properties(cpprestsdk PROPERTIES IMPORTED_LOCATION
        ${DMY_OPENSSL_LIBS_DIR}/${ANDROID_ABI}/libcpprest.a
        )
#-----------------------------------------

include_directories( ${DMY_BOOST_INC_DIR}
        )

include_directories( ${DMY_OPENSSL_INC_DIR}
        )

include_directories( ${DMY_CPPRESTSDK_INC_DIR}
        )

#-----------------------------------------
find_library (log-lib log)

#-----------------------------------------
target_link_libraries( # Specifies the target library.
        native-lib
        ${log-lib}
        boost_system
        boost_chrono
        openssl
        cpprestsdk
        )

Мой build.graddle (приложение) -

apply plugin: 'com.android.application'


def my_boost_dir = local_props("boost.dir")
def my_boost_dir_libs = my_boost_dir + "libs\\llvm"
def my_boost_dir_inc  = my_boost_dir + "/include"

def my_openssl_dir = local_props("openssl.dir")
def my_openssl_dir_libs = my_openssl_dir + "/Prebuilt/armv7-shared/lib"
def my_openssl_dir_inc  = my_openssl_dir + "/Prebuilt/armv7-shared/include/openssl"


def my_cpprestsdk_dir = local_props("cpprestsdk.dir")
def my_cpprestsdk_dir_libs = my_cpprestsdk_dir + "/armeabi-v7a/lib"
def my_cpprestsdk_dir_inc  = my_cpprestsdk_dir + "/include"

андроид { compileSdkVersion 28 defaultConfig { applicationId "com.example.dell.cppaddlibrary" minSdkVersion 27 targetSdkVersion 28 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" externalNativeBuild { cmake { cppFlags "" Аргументы "-DANDROID_STL = c ++ _ shared"

                arguments '-DMY_BOOST_LIBS_DIR=' + my_boost_dir_libs
                arguments '-DMY_BOOST_INC_DIR='  + my_boost_dir_inc

                arguments '-DMY_OPENSSL_LIBS_DIR=' + my_openssl_dir_libs
                arguments '-DMY_OPENSSL_INC_DIR='  + my_openssl_dir_inc

                arguments '-DMY_OPENSSL_LIBS_DIR=' + my_cpprestsdk_dir_libs
                arguments '-DMY_OPENSSL_INC_DIR='  + my_cpprestsdk_dir_inc

            }
        }

        ndk {
            abiFilters 'armeabi-v7a', 'x86', 'x86_64', 'arm64-v8a'
            stl 'c++_shared'
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    externalNativeBuild {
        cmake {
            path "CMakeLists.txt"
        }
    }

    sourceSets {
        main {
           jniLibs.srcDirs = [
                    my_boost_dir_libs,
                   my_openssl_dir_libs,
                    my_cpprestsdk_dir_libs
           ]
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

def local_props(key) { // reads ~ value from local.properties file
    Properties properties = new Properties()
    properties.load(project.rootProject.file('local.properties').newDataInputStream())
    def val = properties.getProperty(key, null)
    if (val == null)
        throw new GradleException("""\
                cant find value '${key}' in file 'local.properties'.  """)

    return val
}

и Local.Properties

ndk.dir=C\:\\Users\\Dell\\AppData\\Local\\Android\\Sdk\\ndk-bundle
boost.dir=C\:\\Users\\Dell\\AppData\\Local\\Android\\Sdk\\ndk-bundle\\boost
openssl.dir=D\:\\Android studio project\\CppAddLibrary\\app\\Prebuilt_OpenSSL
cpprestsdk.dir=D\:\\Android studio project\\CppAddLibrary\\app\\cpprestsdk
sdk.dir=C\:\\Users\\Dell\\AppData\\Local\\Android\\Sdk

Пожалуйста, помогите мне решить эту проблему

Заранее спасибо

Теперь он показывает мне ошибку, как

Build command failed.
Error while executing process C:\Users\Dell\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\cmake.exe with arguments {--build D:\Android studio project\CppAddLibrary\app\.externalNativeBuild\cmake\debug\armeabi-v7a --target native-lib}
[1/1] Linking CXX shared library ..\..\..\..\build\intermediates\cmake\debug\obj\armeabi-v7a\libnative-lib.so
FAILED: cmd.exe /C "cd . && C:\Users\Dell\AppData\Local\Android\Sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe  --target=armv7-none-linux-androideabi27 --gcc-toolchain=C:/Users/Dell/AppData/Local/Android/Sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64 --sysroot=C:/Users/Dell/AppData/Local/Android/Sdk/ndk-bundle/sysroot -fPIC -isystem C:/Users/Dell/AppData/Local/Android/Sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -mfpu=neon -Wa,--noexecstack -Wformat -Werror=format-security -std=c++11 -frtti -fexceptions -DBOOST_SYSTEM_NO_DEPRECATED -O0 -fno-limit-debug-info  -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libatomic.a -nostdlib++ --sysroot C:/Users/Dell/AppData/Local/Android/Sdk/ndk-bundle/platforms/android-27/arch-arm -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--fix-cortex-a8 -Wl,--exclude-libs,libunwind.a -LC:/Users/Dell/AppData/Local/Android/Sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a -Wl,--no-undefined -Wl,-z,noexecstack -Qunused-arguments -Wl,-z,relro -Wl,-z,now -shared -Wl,-soname,libnative-lib.so -o ..\..\..\..\build\intermediates\cmake\debug\obj\armeabi-v7a\libnative-lib.so CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o  -llog C:/Users/Dell/AppData/Local/Android/Sdk/ndk-bundle/boost/libs/llvm/armeabi-v7a/libboost_system.so C:/Users/Dell/AppData/Local/Android/Sdk/ndk-bundle/boost/libs/llvm/armeabi-v7a/libboost_chrono.so -lopenssl ../../../../cpprestsdk/lib/armeabi-v7a/libcpprest.a -latomic -lm "C:/Users/Dell/AppData/Local/Android/Sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/libunwind.a" "C:/Users/Dell/AppData/Local/Android/Sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/libc++_shared.so" && cd ."
C:/Users/Dell/AppData/Local/Android/Sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin\ld: error: cannot find -lopenssl`enter code here`

1 Ответ

0 голосов
/ 01 ноября 2018
set_target_properties( boost_system PROPERTIES IMPORTED_LOCATION
        ${-DMY_BOOST_LIBS_DIR}/${ANDROID_ABI}/libboost_system.so
        )

Что должно быть ${-DMY_BOOST_LIBS_DIR}? Эта переменная ничего не вычисляет, поэтому вы получаете неправильный путь.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...