0
如何使用gradle構建共享庫?帶有gradle的JNI
我的項目樹
核心/ C/{* C,是* .h}
核心/ C /包括/ {JNI,LIB}
我的身材。 gradle這個
apply plugin: 'c'
def JNI_INCLUDE_DIR = this.properties['jni.include.dir']
model {
components {
bridge(NativeLibrarySpec) {
sources.c.source {
srcDir 'core/c'
include '**/*.c'
}
sources.c.exportedHeaders {
srcDir 'core/c/include'
}
buildTypes {
debug
release
}
}
}
toolChains {
gcc(Gcc) {
if(System.properties['os.name'].equals("Mac OS X")) {
cCompiler.withArguments {
args << "-I" + JNI_INCLUDE_DIR
args << "-I" + JNI_INCLUDE_DIR + "/darwin"
args << "-std=gnu11"
args << "-g"
}
} else {
cCompiler.withArguments {
args << "-I" + JNI_INCLUDE_DIR
args << "-I" + JNI_INCLUDE_DIR + "/linux"
args << "-std=gnu11"
args << "-g"
}
}
}
}
}
錯誤
執行模型規則時拋出異常:toolChains {...} @ build.gradle第23行,第2列 無法獲取類型爲org.gradle的工具鏈'gcc'(GNU GCC)的未知屬性'cCompiler'。 nativeplatform.toolchain.internal.gcc.GccToolChain。