Closed eSKond closed 3 weeks ago
could you show me :
ndk-pkg
commands you runbuild.gradle
CMakeLists.txt
buildscript {
repositories {
google()
mavenCentral()
mavenLocal()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.4.1'
}
}
repositories { google() mavenCentral() mavenLocal() }
apply plugin: 'com.android.application'
dependencies { implementation fileTree(dir: 'libs', include: ['.jar', '.aar']) implementation 'androidx.core:core:1.10.1' implementation 'com.fpliu.ndk.pkg.prefab.android.34:libssh:0.10.6@aar' }
android { /***
Changing them manually might break the compilation! ***/
compileSdkVersion androidCompileSdkVersion buildToolsVersion androidBuildToolsVersion ndkVersion androidNdkVersion
// Extract native libraries from the APK packagingOptions.jniLibs.useLegacyPackaging true
sourceSets { main { manifest.srcFile 'AndroidManifest.xml' java.srcDirs = [qtAndroidDir + '/src', 'src', 'java'] aidl.srcDirs = [qtAndroidDir + '/src', 'src', 'aidl'] res.srcDirs = [qtAndroidDir + '/res', 'res'] resources.srcDirs = ['resources'] renderscript.srcDirs = ['src'] assets.srcDirs = ['assets'] jniLibs.srcDirs = ['libs'] } }
tasks.withType(JavaCompile) { options.incremental = true }
compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 }
lintOptions { abortOnError false }
// Do not compress Qt binary resources file aaptOptions { noCompress 'rcc' }
defaultConfig { resConfig "en" minSdkVersion qtMinSdkVersion targetSdkVersion qtTargetSdkVersion ndk.abiFilters = qtTargetAbiList.split(",") }
buildFeatures { prefab true } }
3.
cmake_minimum_required(VERSION 3.16)
project(myapp VERSION 0.1 LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(Qt6 6.5 REQUIRED COMPONENTS Quick)
qt_standard_project_setup(REQUIRES 6.5)
...
find_package(libssh REQUIRED CONFIG)
qt_add_executable(appmyapp main.cpp ... MANUAL_FINALIZATION )
qt_add_qml_module(appmyapp URI myapp VERSION 1.0 QML_FILES Main.qml MainPage.qml ... RESOURCES android/AndroidManifest.xml android/build.gradle android/res/values/libs.xml android/res/values/strings.xml android/res/xml/qtprovider_paths.xml android/gradle/wrapper/gradle-wrapper.jar android/gradle/wrapper/gradle-wrapper.properties android/gradle.properties android/gradlew android/gradlew.bat SOURCES ... )
set_target_properties(appmyapp PROPERTIES
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
MACOSX_BUNDLE TRUE
WIN32_EXECUTABLE TRUE
)
set_property(TARGET appmyapp APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/android )
target_include_directories(appmyapp PRIVATE ${SOME_INCLUDE_DIRS}) target_link_libraries(appmyapp PRIVATE Qt6::Quick ... libssh::libssh.a )
include(GNUInstallDirs) install(TARGETS appmyapp BUNDLE DESTINATION . LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} )
qt_finalize_executable(appmyapp)
libssh's dependencies are also should be deploied by yourself.
./ndk-pkg deploy android-34-arm64-v8a/openssl-dev
./ndk-pkg deploy android-34-arm64-v8a/libz
./ndk-pkg deploy android-34-arm64-v8a/libssh
implementation 'com.fpliu.ndk.pkg.prefab.android.34:openssl-dev:3.3.0@aar'
implementation 'com.fpliu.ndk.pkg.prefab.android.34:libz:1.3.1@aar'
implementation 'com.fpliu.ndk.pkg.prefab.android.34:libssh:0.10.6@aar'
find_package(openssl-dev REQUIRED CONFIG)
find_package(libz REQUIRED CONFIG)
find_package(libssh REQUIRED CONFIG)
target_link_libraries(app libssh::libssh.so)
target_link_libraries(app libz::libz.so)
target_link_libraries(app openssl-dev::libcrypto.so)
i just tried link openssl-dev and it have same error:
CMake Error at CMakeLists.txt:192 (find_package):
Could not find a package configuration file provided by "openssl-dev" with
any of the following names:
openssl-devConfig.cmake
openssl-dev-config.cmake
Add the installation prefix of "openssl-dev" to CMAKE_PREFIX_PATH or set
"openssl-dev_DIR" to a directory containing one of the above files. If
"openssl-dev" provides a separate development package or SDK, be sure it
has been installed.
Could you explain how cmake should find package if there is no any path to ndp-pkg or maven repository in CMakeLists.txt?
btw i can link all libraries with something like:
set(NDK_PKG_HOME_DIR /Users/sergey/.ndk-pkg)
add_library(
libssh
STATIC
IMPORTED
)
set_target_properties(
libssh
PROPERTIES IMPORTED_LOCATION
${NDK_PKG_HOME_DIR}/installed/android-34-arm64-v8a/libssh/lib/libssh.a
)
but perhaps it's not expected way of using ndk-pkg, right?
i just tried link openssl-dev and it have same error:
CMake Error at CMakeLists.txt:192 (find_package): Could not find a package configuration file provided by "openssl-dev" with any of the following names: openssl-devConfig.cmake openssl-dev-config.cmake Add the installation prefix of "openssl-dev" to CMAKE_PREFIX_PATH or set "openssl-dev_DIR" to a directory containing one of the above files. If "openssl-dev" provides a separate development package or SDK, be sure it has been installed.
Could you explain how cmake should find package if there is no any path to ndp-pkg or maven repository in CMakeLists.txt?
I tried locally, it works for me.
btw i can link all libraries with something like:
set(NDK_PKG_HOME_DIR /Users/sergey/.ndk-pkg) add_library( libssh STATIC IMPORTED ) set_target_properties( libssh PROPERTIES IMPORTED_LOCATION ${NDK_PKG_HOME_DIR}/installed/android-34-arm64-v8a/libssh/lib/libssh.a )
but perhaps it's not expected way of using ndk-pkg, right?
It works but not a normal way.
find_package(openssl-dev REQUIRED CONFIG)
find_package(libz REQUIRED CONFIG)
find_package(libssh REQUIRED CONFIG)
target_link_libraries(app libssh::libssh.so)
target_link_libraries(app libz::libz.so)
target_link_libraries(app openssl-dev::libcrypto.so)
or
find_package(openssl-dev REQUIRED CONFIG)
find_package(libz REQUIRED CONFIG)
find_package(libssh REQUIRED CONFIG)
target_link_libraries(app libssh::libssh.a)
target_link_libraries(app libz::libz.a)
target_link_libraries(app openssl-dev::libcrypto.a)
see my message above - i tried link only libz or openssl-dev - same problem - cmake can't find package. It may be related with some macos individual issues, i don't know. Btw, now, after few attempts uninstall/reinstall/install it started ignore --static and installs libssh.so without libssh.a, but after few more reinstallation (including ndk-pkg) it stopped install (can't find formulae) any library. So i'm sorry for boring you, i'm going to stop attempts to use ndk-pkg in my project, so let close this thread.
I'm sorry. my local test works well. This is a example https://github.com/leleliu008/android-calendar-for-the-aged , but it use Kotlin script not Groovy script.
btw i can link all libraries with something like:
set(NDK_PKG_HOME_DIR /Users/sergey/.ndk-pkg) add_library( libssh STATIC IMPORTED ) set_target_properties( libssh PROPERTIES IMPORTED_LOCATION ${NDK_PKG_HOME_DIR}/installed/android-34-arm64-v8a/libssh/lib/libssh.a )
but perhaps it's not expected way of using ndk-pkg, right?
This is actually what the Android Gradle Plugin doing.
AGP generates app/.cxx/RelWithDebInfo/3g645a1v/prefab/arm64-v8a/prefab/lib/aarch64-linux-android/cmake/openssl-dev/openssl-devConfig.cmake
if(NOT TARGET openssl-dev::headers)
add_library(openssl-dev::headers INTERFACE IMPORTED)
set_target_properties(openssl-dev::headers PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "/home/leleliu008/.gradle/caches/transforms-3/fde0bd0333cf75f28a02aa4fabb6221d/transformed/openssl-dev-3.3.0/prefab/modules/headers/include"
INTERFACE_LINK_LIBRARIES ""
)
endif()
if(NOT TARGET openssl-dev::libcrypto.a)
add_library(openssl-dev::libcrypto.a STATIC IMPORTED)
set_target_properties(openssl-dev::libcrypto.a PROPERTIES
IMPORTED_LOCATION "/home/leleliu008/.gradle/caches/transforms-3/fde0bd0333cf75f28a02aa4fabb6221d/transformed/openssl-dev-3.3.0/prefab/modules/libcrypto.a/libs/android.arm64-v8a/libcrypto.a"
INTERFACE_INCLUDE_DIRECTORIES "/home/leleliu008/.gradle/caches/transforms-3/fde0bd0333cf75f28a02aa4fabb6221d/transformed/openssl-dev-3.3.0/prefab/modules/libcrypto.a/libs/android.arm64-v8a/include"
INTERFACE_LINK_LIBRARIES ""
)
endif()
if(NOT TARGET openssl-dev::libcrypto.so)
add_library(openssl-dev::libcrypto.so SHARED IMPORTED)
set_target_properties(openssl-dev::libcrypto.so PROPERTIES
IMPORTED_LOCATION "/home/leleliu008/.gradle/caches/transforms-3/fde0bd0333cf75f28a02aa4fabb6221d/transformed/openssl-dev-3.3.0/prefab/modules/libcrypto.so/libs/android.arm64-v8a/libcrypto.so"
INTERFACE_INCLUDE_DIRECTORIES "/home/leleliu008/.gradle/caches/transforms-3/fde0bd0333cf75f28a02aa4fabb6221d/transformed/openssl-dev-3.3.0/prefab/modules/libcrypto.so/libs/android.arm64-v8a/include"
INTERFACE_LINK_LIBRARIES ""
)
endif()
if(NOT TARGET openssl-dev::libssl.a)
add_library(openssl-dev::libssl.a STATIC IMPORTED)
set_target_properties(openssl-dev::libssl.a PROPERTIES
IMPORTED_LOCATION "/home/leleliu008/.gradle/caches/transforms-3/fde0bd0333cf75f28a02aa4fabb6221d/transformed/openssl-dev-3.3.0/prefab/modules/libssl.a/libs/android.arm64-v8a/libssl.a"
INTERFACE_INCLUDE_DIRECTORIES "/home/leleliu008/.gradle/caches/transforms-3/fde0bd0333cf75f28a02aa4fabb6221d/transformed/openssl-dev-3.3.0/prefab/modules/libssl.a/libs/android.arm64-v8a/include"
INTERFACE_LINK_LIBRARIES ""
)
endif()
if(NOT TARGET openssl-dev::libssl.so)
add_library(openssl-dev::libssl.so SHARED IMPORTED)
set_target_properties(openssl-dev::libssl.so PROPERTIES
IMPORTED_LOCATION "/home/leleliu008/.gradle/caches/transforms-3/fde0bd0333cf75f28a02aa4fabb6221d/transformed/openssl-dev-3.3.0/prefab/modules/libssl.so/libs/android.arm64-v8a/libssl.so"
INTERFACE_INCLUDE_DIRECTORIES "/home/leleliu008/.gradle/caches/transforms-3/fde0bd0333cf75f28a02aa4fabb6221d/transformed/openssl-dev-3.3.0/prefab/modules/libssl.so/libs/android.arm64-v8a/include"
INTERFACE_LINK_LIBRARIES ""
)
endif()
I'm sorry but i don't understand how to use ndk-pkg installed packages in cmake projects. And yes, i have read documentation hundred times, moreover i have read instructions shown in terminal on ndk-pkg deploy. I added all suggested to build.gradle, i added all suggested to CMakeLists.txt but building says:
CMake Error at CMakeLists.txt:188 (find_package): Could not find a package configuration file provided by "somelib" with any of the following names:
somelibConfig.cmake somelib-config.cmake
Add the installation prefix of "somelib" to CMAKE_PREFIX_PATH or set "somelib_DIR" to a directory containing one of the above files. If "somelib" provides a separate development package or SDK, be sure it has been installed.
What do i do wrong?