Stefan Oltmann
02/24/2023, 4:03 PMkotlin {
mingwX64("native") {
binaries {
executable()
}
}
}
That results in ModuleVersionNotFoundException: Could not find :kotlin-native-prebuilt-windows-aarch64:1.6.10.
I am currently using the ARM version of Windows 11, which has the ability to run x64 code. I would like to know how I can modify my Gradle configuration to prioritize the use of the x64 version instead of searching for the aarch64 version.Roberto Leinardi
02/27/2023, 10:02 AMg_string_append_printf
, which is mapped with this:
@kotlinx.cinterop.internal.CCall public external fun g_string_append_printf(string: kotlinx.cinterop.CValuesRef<native.glib.GString /* = native.glib._GString */>?, @kotlinx.cinterop.internal.CCall.CString format: kotlin.String?, vararg variadicArguments: kotlin.Any?): kotlin.Unit { /* compiled code */ }
It seems to expect a vararg variadicArguments: kotlin.Any?
, but if I send that to it like this:
public fun appendPrintf(format: String, vararg variadicArguments: Any): Unit {
g_string_append_printf(cPointer.reinterpret(), format, variadicArguments)
}
I get this error when I build the module:
type kotlin.Array<out kotlin.Any> is not supported here: doesn't correspond to any C type
The GIR parameter only gives a name (...
) and has a tag `varargs`:
<parameter name="..." transfer-ownership="none">
<doc xml:space="preserve"
filename="glib-2.0.c"
line="32361">the parameters to insert into the format string</doc>
<varargs/>
</parameter>
But there are no other information about the type.
I am an Android developer and not very familiar with C Interop. Does anyone have a suggestion of what this vararg variadicArguments: kotlin.Any?
should be converted to?David Herman
02/27/2023, 8:39 PMtermios
in K/N. termios
is a struct which has a bitflag field called c_lflag
; its type is platform.posix.tcflag_t
which appears to be an int on mac and a uint on linux.
I'm trying to do some bit logic like this: newTermios.c_lflag.and((_ECHO_.or(_ICANON_.or(_IEXTEN_))).inv())
(equivalent to c_lflag & ~(ECHO | ICNON | IEXTEN)
in C).
In order to support both targets, I thought ECHO.or(...) as tcflag_t
would work, but I'm getting a warning that the cast will never succeed.
What's the right solution here?vbsteven
02/28/2023, 8:13 AMgtk-rs
case in Rust land they handle it with Cargo features where an application developer can depend on the gtk4
crate which exposes the 4.0
API by default and features = [4_2]
can be used in Cargo.toml to unlock newer API functions.
- One possible solution is to have different library versions for each upstream dependency version but that can get unwieldy quickly.
- Maybe something is possible with Kotlin annotations that conditionally enable additional methods based on properties in Gradle (equivalent to Cargo features).
- Another approach could be to not distribute generated bindings and instead wrap the bindings-generator (GIR-based) into a Gradle plugin that is configured with the desired library version in the gradle DSL and generates the bindings at build-time.
Has anyone already done something like this? Any thoughts?Roberto Leinardi
02/28/2023, 3:52 PMType mismatch: inferred type is GtkCellAllocCallback /* = CPointer<CFunction<(CPointer<GtkCellRenderer /* = _GtkCellRenderer */>?, CPointer<GdkRectangle /* = native.gdk._cairo_rectangle_int */>?, CPointer<GdkRectangle /* = native.gdk._cairo_rectangle_int */>?, CPointer<out CPointed>?) -> gboolean /* = Int */>> */ but GtkCellAllocCallback? /* = CPointer<CFunction<(CPointer<GtkCellRenderer /* = _GtkCellRenderer */>?, CPointer<GdkRectangle /* = native.gtk._cairo_rectangle_int */>?, CPointer<GdkRectangle /* = native.gtk._cairo_rectangle_int */>?, gpointer? /* = CPointer<out CPointed>? */) -> gboolean /* = Int */>>? */ was expected
I really don't get what the issue is: it is expecting a GtkCellAllocCallback?
and I'm giving it a GtkCellAllocCallback?
. Does anyone have a clue of what the issue could be?Duane Malcolm
03/01/2023, 7:19 PMvar bar: String = "5"
var foo: String
get() { return bar }
set(value: String) { bar = value }
set(value: Int) { bar = value.toString() }
set(value: Float) { bar = round(value).toInt().toString() }
Omico
03/02/2023, 12:46 AMGetFileVersionInfoSizeW
function is in the platform.windows.*
package, but why am I getting lld-link: error: undefined symbol: GetFileVersionInfoSizeW
?felix
03/02/2023, 8:29 AMbuild.gradle.kts
plugins {
kotlin("native.cocoapods")
...
kotlin {
cocoapods {
pod("pod_a") {
version = "1.0"
source = path(project.file("../pod_a"))
}
pod("pod_b") {
version = "1.0"
source = path(project.file("../pod_b"))
}
...
e.g. How can I disable cinterop for pod_a?Mitchell Syer
03/04/2023, 4:24 AMLucy
03/05/2023, 3:44 AMIgnat Beresnev
03/05/2023, 8:30 AM.dll
) library on Windows. If I build a vanilla Kotlin/Native project, the DLL exported symbols seem to be all public functions (screenshot 1). My own top-level @CName
function is exported, I can see it.
However, if I add an implementation dependency on kotlin-libui (cc @msink), DLL exported symbols are UI only (screenshot 2). My top-level @CName
function is NOT exported, neither are any other K/N functions. Looks like the exports are taken from libui only and the rest is ignored. The .def
and .h
files are the same, so they contain my top-level function, but of course it fails in runtime whenever I try to load the DLL.
kotlin {
val nativeMain by sourceSets.getting {
dependencies {
implementation("com.github.msink:libui:0.1.8")
}
}
}
Is there a way to tell the compiler to export all public functions, or override the list? I tried multiple options (including linker ones), tried removing exports from libui and some other things - nothing helped 😞 I basically want both ui and my own top-level function to be exported.jeggy
03/06/2023, 10:07 AMvbsteven
03/06/2023, 6:59 PMcinterop
route to interpret headers? So manually writing (or generating) the necessary @CCall
functions to call into a native library.
Is there a reason why I should not attempt this?Sam
03/08/2023, 10:58 PMsmbd uknow
03/09/2023, 12:58 PMvoid kotlin::RepeatedTimer<kotlin::steady_clock>::Run<kotlin::gc::internal::GCSchedulerDataWithTimer<kotlin::steady_clock>::GCSchedulerDataWithTimer(kotlin::gc::GCSchedulerConfig&, std::__1::function<void ()>)::'lambda'()>(kotlin::gc::internal::GCSchedulerDataWithTimer<kotlin::steady_clock>::GCSchedulerDataWithTimer(kotlin::gc::GCSchedulerConfig&, std::__1::function<void ()>)::'lambda'()&&) + 4373751076
4
void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)(kotlin::ScopedThread::attributes, void (kotlin::RepeatedTimer<kotlin::steady_clock>::*&&)(kotlin::gc::internal::GCSchedulerDataWithTimer<kotlin::steady_clock>::GCSchedulerDataWithTimer(kotlin::gc::GCSchedulerConfig&, std::__1::function<void ()>)::'lambda'()&&) noexcept, kotlin::RepeatedTimer<kotlin::steady_clock>*&&, kotlin::gc::internal::GCSchedulerDataWithTimer<kotlin::steady_clock>::GCSchedulerDataWithTimer(kotlin::gc::GCSchedulerConfig&, std::__1::function<void ()>)::'lambda'()&&), kotlin::ScopedThread::attributes, void (kotlin::RepeatedTimer<kotlin::steady_clock>::*)(kotlin::gc::internal::GCSchedulerDataWithTimer<kotlin::steady_clock>::GCSchedulerDataWithTimer(kotlin::gc::GCSchedulerConfig&, std::__1::function<void ()>)::'lambda'()&&) noexcept, kotlin::RepeatedTimer<kotlin::steady_clock>*, kotlin::gc::internal::GCSchedulerDataWithTimer<kotlin::steady_clock>::GCSchedulerDataWithTimer(kotlin::gc::GCSchedulerConfig&, std::__1::function<void ()>)::'lambda'()> >(void*) + 4373751760
GC thread
std::__1::invoke_result<kotlin::gc::ConcurrentMarkAndSweep::ConcurrentMarkAndSweep(kotlin::mm::ObjectFactory<kotlin::gc::ConcurrentMarkAndSweep>&, kotlin::gc::GCScheduler&)::$_2>::type kotlin::ScopedThread::Run<kotlin::gc::ConcurrentMarkAndSweep::ConcurrentMarkAndSweep(kotlin::mm::ObjectFactory<kotlin::gc::ConcurrentMarkAndSweep>&, kotlin::gc::GCScheduler&)::$_2>(kotlin::ScopedThread::attributes, kotlin::gc::ConcurrentMarkAndSweep::ConcurrentMarkAndSweep(kotlin::mm::ObjectFactory<kotlin::gc::ConcurrentMarkAndSweep>&, kotlin::gc::GCScheduler&)::$_2&&) + 4373763056
4
void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)(kotlin::ScopedThread::attributes, kotlin::gc::ConcurrentMarkAndSweep::ConcurrentMarkAndSweep(kotlin::mm::ObjectFactory<kotlin::gc::ConcurrentMarkAndSweep>&, kotlin::gc::GCScheduler&)::$_2&&), kotlin::ScopedThread::attributes, kotlin::gc::ConcurrentMarkAndSweep::ConcurrentMarkAndSweep(kotlin::mm::ObjectFactory<kotlin::gc::ConcurrentMarkAndSweep>&, kotlin::gc::GCScheduler&)::$_2> >(void*) + 4373768160
We use Kotlin 1.7.20vbsteven
03/11/2023, 9:45 PMstrictEnums
or nonStrictEnums
without using the heuristics mentioned on https://kotlinlang.org/docs/native-c-interop.html#definition-file-hints ?Omico
03/14/2023, 9:48 AMkotlin {
macosX64()
linuxX64()
mingwX64()
targets.withType<KotlinNativeTarget> {
compilations["main"].cinterops {
create("tdlib")
}
}
}
linkerOpts = \
-ltdactor \
-ltdapi \
-ltdclient \
-ltdcore \
-ltddb \
-ltdjson \
-ltdjson_private \
-ltdjson_static \
-ltdnet \
-ltdsqlite \
-ltdutils
linkerOpts.mingw = \
-I"D:\Git\Omico\telegram-bot\TDLib\tdlib\include" \
-L"D:\Git\Omico\telegram-bot\TDLib\tdlib\lib"
willflier
03/14/2023, 11:20 AM_NSGetExecutablePath()
function in K/N macos target.Big Chungus
03/14/2023, 5:07 PMvbsteven
03/15/2023, 7:38 PMval application = Application("myapp", ApplicationFlags.NONE.or(ApplicationFlags.REPLACE))
where I want the signature to read something like
class Application(val name: String, flags: ApplicationFlags)
So the user does not have to go hunt for random constants.Jack
03/16/2023, 12:31 PMCarl Hickman
03/16/2023, 2:32 PMLandry Norris
03/16/2023, 6:06 PMDavid Herman
03/16/2023, 8:27 PMplatform.posix.TIOCGWINSZ
showing up as undefined on macos. But as far as I can tell, that constant should be supported on the mac platform?Lucy
03/17/2023, 1:38 AMJiaxiang
03/17/2023, 6:23 PMCould not initialize class org.jetbrains.kotlin.backend.konan.env.env
, does anyone know what could be the cause?spierce7
03/18/2023, 2:49 PMstaticCFunction { cByte, _ ->
val c = cByte.toInt().toChar()
print(c)
}
The streaming gets backed up and starts to significantly lag on Windows Machines. The same code on Mac seems to perform fine. We've removed the print, and started buffering the characters before we print (so we only print once a line). The issue is still present.
The same code in C++ doesn't have the same performance issues. What else could we do to improve performance in Kotlin?Sergey Aldoukhov
03/20/2023, 2:51 AMDavid Herman
03/20/2023, 5:48 AMDaniel
03/20/2023, 5:32 PMrepo.login(email: $userId.wrappedValue, password: $password.wrappedValue) { user, error in
}
I have 2 methods that login identically on my Realm repository.
suspend fun login(email: String, password: String): User {
return appService.login(Credentials.emailPassword(email, password))
}
suspend fun dologin(email: String, password: String): User {
return appService.login(Credentials.emailPassword(email, password))
}
But just the first login works: repo.login
Whenever I try to use the second login: repo.dologin
, it will show the exception:
libc++abi: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[SharedRealmRepo dologinEmail:password:completionHandler:]: unrecognized selector sent to instance 0x281fe4960'
terminating with uncaught exception of type NSException
Why this happens? Do I need to recompile the shared module in some way?