nayanjyoti
10/18/2018, 7:27 PMplugins {
id 'kotlin-multiplatform' version '1.3.0-rc-146'
}
repositories {
maven { url '<http://dl.bintray.com/kotlin/kotlin-eap>' }
mavenCentral()
}
group 'com.example.sample'
version '0.0.1'
apply plugin: 'maven-publish'
kotlin {
targets {
fromPreset(presets.jvm, 'jvm')
fromPreset(presets.js, 'js')
// For ARM, preset should be changed to presets.iosArm32 or presets.iosArm64
// For Linux, preset should be changed to e.g. presets.linuxX64
// For MacOS, preset should be changed to e.g. presets.macosX64
fromPreset(presets.macosX64, 'macos')
}
sourceSets {
commonMain {
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-stdlib-common'
}
}
commonTest {
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-test-common'
implementation 'org.jetbrains.kotlin:kotlin-test-annotations-common'
}
}
jvmMain {
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
}
}
jvmTest {
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-test'
implementation 'org.jetbrains.kotlin:kotlin-test-junit'
}
}
jsMain {
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-stdlib-js'
}
}
jsTest {
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-test-js'
}
}
macosMain {
dependencies {
}
}
macosTest {
}
}
}
in the macos main module i want to include the ncurses library.
So I changed the part as
macosMain {
dependencies {
cinterop('ncurses') {
// something more
}
}
}
I am getting error Could not find method cinterop() for arguments [ncurses, build_1mx5jx84o9toi8bpdxyehixos$_run_closure2$_closure6$_closure13$_closure21$_closure22@836eb38] on object of type org.jetbrains.kotlin.gradle.plugin.mpp.DefaultKotlinDependencyHandler.
Also I’m a total newbie to c/cpp or native world, so i may be doing something really stupid. if anyone can help i would b really grateful.orangy
fromPreset(presets.macosX64, 'sdl2macos') {
compilations.main {
cinterops {
sdl {
defFile = file("sdl2/interop/sdl2.def")
}
}
}
}
nayanjyoti
10/18/2018, 8:34 PMheaders = /usr/local/opt/ncurses/include/ncurses.h
headerFilter = /usr/local/opt/ncurses/include/ncursesw/*
linkerOpts.osx = -L/usr/local/opt/ncurses/lib -lncurses
The paths are all okay. the file /usr/local/opt/ncurses/include/ncurses.h
is the header file from the installation of homebrew on mac mojave.
I used the command cinterop -def src/macosMain/ncurses.def -compilerOpts -I/usr/local/opt/ncurses/include -o src/macosMain/lib/ncurses
to generate the binding to look into the functions.
On executing, a kotlin file is created at the path src/macosMain/lib/ncurses-build/kotlin/ncurses/ncurses.kt
. The content od the file is empty. (apart from the package import and @file statements).content is below
@file:kotlinx.cinterop.InteropStubs
@file:Suppress("UNUSED_VARIABLE", "UNUSED_EXPRESSION")
package ncurses
import kotlin.native.SymbolName
import kotlinx.cinterop.*
// NOTE THIS FILE IS AUTO-GENERATED
This doesn’t seem right. I’m not even sure if I’m doing the right thing here. 😞orangy
cinterop
manually, gradle task should handle it for you. Please check https://github.com/JetBrains/kotlin-native/blob/master/INTEROP.md for more information about .def
filesorangy
nayanjyoti
10/18/2018, 8:42 PMnayanjyoti
10/18/2018, 8:43 PMfromPreset(presets.macosX64, 'macos') {
compilations.main {
cinterops {
ncurses {
defFile = file('src/macosMain/ncurses.def')
includeDirs '/usr/local/opt/ncurses/include'
}
}
}
}