I am trying to add c++ native project to my library project.
I have followed this tutorial
and I get fatal error: 'sys/sysctl.h' file not found
can't figure out why.
I have followed this steps:
1) create a JNI Folder and put there all the source files and the wrapper.
2) created CMakeLIsts.txt
This is my CMakeLIsts.txt :
cmake_minimum_required(VERSION 3.4.1)
add_library(pHash-jni SHARED
pHash-jni.cpp)
target_link_libraries(pHash-jni log android)
3) updated my local.propreties to this :
ndk.dir=/home/maxim/Android/Sdk/ndk-bundle
sdk.dir=/home/maxim/Android/Sdk
4) updated build.gradle to this :
apply plugin: 'com.android.library'
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
arguments '-DANDROID_TOOLCHAIN=clang'
cppFlags "-fexceptions"
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
externalNativeBuild {
cmake {
path "src/main/jni/CMakeLists.txt"
}
}
productFlavors {
arm7 {
// in the future, ndk.abiFilter might also work
ndk {
abiFilter 'armeabi-v7a'
}
}
arm8 {
ndk {
abiFilters 'arm64-v8a'
}
}
arm {
ndk {
abiFilter 'armeabi'
}
}
x86 {
ndk {
abiFilter 'x86'
}
}
x86_64 {
ndk {
abiFilter 'x86_64'
}
}
mips {
ndk {
abiFilters 'mips', 'mips64'
}
}
all {
ndk {
abiFilters 'mips', 'mips64', 'x86', 'x86_64'
}
}
}
sourceSets { main { jni.srcDirs = ['src/main/jni', 'src/main/jni/'] } }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:24.2.1'
testCompile 'junit:junit:4.12'
}
5) updated gradle.properties to with this :
android.useDeprecatedNdk=true
$ find android-ndk-r13/platforms/ -name sysctl.h
../../android-ndk-r13/platforms/android-19/arch-arm/usr/include/linux/sysctl.h
more of the same...
Android doesn't have <sys/sysctl.h>, but it does have <linux/sysctl.h>.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With