stoyicker
03/15/2024, 12:16 PMaxeon
03/17/2024, 7:52 AMgradle publish
, only a .jar
file gets published. Afaik, it's necessary to include a .klib
as well for it to be used in other Native projects, and the problem is that publishing does not generate/upload that .klib
file.
Build file:
https://github.com/reblast/KPresence/blob/master/build.gradle.ktsTobias
03/18/2024, 6:22 PMktgio
- but maybe I have some bit shiffting issues.Tobias
03/19/2024, 4:01 PMString.format()
at the moment.Tobias
03/21/2024, 10:00 AMTrey
03/21/2024, 8:51 PMPTChannelManagerDelegateProtocol
in iosMain and I'm getting "Conflicting overloads"
exceptions. The confusing part to me is that the methods all have unique parameter names. Here is an example of two methods:
public open fun channelManager(channelManager: PTChannelManager, didActivateAudioSession: AVAudioSession):
public open fun channelManager(channelManager: PTChannelManager, didDeactivateAudioSession: AVAudioSession):
How do I resolve these errors?axeon
03/23/2024, 8:58 AMMatas Lauzadis
03/25/2024, 2:39 PMCValue<CFunction<...>>
which is impossible to use, I'm wondering if I'm missing something.
I have some C code that looks like this:
// from <https://github.com/awslabs/aws-c-auth/blob/main/include/aws/auth/credentials.h>
typedef void(aws_on_get_credentials_callback_fn)(struct aws_credentials *credentials, int error_code, void *user_data);
typedef int(aws_credentials_provider_get_credentials_fn)(
struct aws_credentials_provider *provider,
aws_on_get_credentials_callback_fn callback, // note: not a pointer, but used as one
void *user_data);
and this is what cinterop generates:
public typealias aws_credentials_provider_get_credentials_fn = kotlinx.cinterop.CFunction<(kotlinx.cinterop.CPointer<libcrt.aws_credentials_provider>?, kotlinx.cinterop.CValue<libcrt.aws_on_get_credentials_callback_fn>, kotlinx.cinterop.COpaquePointer?) -> kotlin.Int>
Focusing on the callback
, cinterop generates it as a CValue<CFunction<...>>
, but from what I can tell, this is not possible because CValue
takes a T: CVariable
which does not include CFunction
.
Ideally this callback would be generated as a CPointer<CFunction<...>>
. I understand it's not explicitly a pointer in the source code, but that's the intended use, and currently what cinterop generates is unusable.
Has anyone else come across this issue working with CValue functions? My current workaround is to create duplicate implementations that declare the function as a pointer (i.e aws_on_get_credentials_callback_fn *callback
), but I'm wondering if there's an easier way.Andrey
03/25/2024, 4:46 PMjava.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "hello" referenced by "/data/app/~~5wdEQm0yie2eojravmIojg==/kotlin.test-AITs0CaDTdEGYj6PdueKLA==/lib/arm64/libtest.so"...
at java.lang.Runtime.loadLibrary0(Runtime.java:1077)
at java.lang.Runtime.loadLibrary0(Runtime.java:998)
at java.lang.System.loadLibrary(System.java:1656)
My def file looks like this:
package = api
headers = api.h
headerFilter = api.h
staticLibraries = libapi.a
libraryPaths = staticlib
compilerOpts = -Istaticlib
linkerOpts = -Lstaticlib
libraryPaths = staticlib
Any ideas pleaseEdoardo Luppi
03/27/2024, 3:53 PMstoyicker
03/28/2024, 5:50 PMkotlin {
jvm()
listOf(
macosX64(),
macosArm64(),
iosX64(),
iosArm64(),
iosSimulatorArm64(),
tvosSimulatorArm64(),
tvosX64(),
tvosArm64(),
).forEach {
it.binaries.framework {
baseName = project.name
isStatic = true
}
it.compilations.configureEach {
cinterops.create("cinterop") {
defFile(project.file("src/appleMain/cinterop/network_framework.def"))
}
}
}
}
Marc
03/28/2024, 9:07 PMaxeon
03/30/2024, 5:07 PMNathan Bedell
04/02/2024, 12:40 PMtylerwilson
04/03/2024, 2:06 PMMiguel Santos
04/08/2024, 9:43 AMcompileNativeMainKotlinMetadata
:
e: file:///Users/myuser/Projects/demo/src/nativeMain/Main.kt:12:8 Unresolved reference: libpq
In summary:
Linux machine (x64):
• linuxX64 ✅
• linuxArm64 ❌ (I think it's supposed to work)
Macos machine (arm64):
• macosX64 ✅
• macosArm64 ✅
• linuxX64 ❌
• linuxArm64 ❌
Not sure why linuxX64 works on Linux machine but not Macos. Appreciate if someone could provide help or even a way to debug this issue (not sure where to start).Marc
04/08/2024, 11:06 AMoverride suspend fun ArcherRaise.invoke(q: KeyQuery<K, out A>): A & Any =
println(q)
println(this)
println(this@invoke)
when (q) {
is Put -> {
q.value?.also { values[q.key] = it } ?: raise(DataNotFound)
}
is Get -> {
values[q.key] ?: raise(DataNotFound)
}
}
ArcherRaise
is a custom object that I use for scoping the invoke function of my class. The issue is that when I’m running the code println(q)
prints ArcherRaise(raise=0)
where q is a totally different type, a KeyQuery
. This is causing a runtime exception: kotlin.NoWhenBranchMatchedException
note: on JVM this works as expectedRohan Maity
04/10/2024, 5:08 AMld: unknown options: -ios_simulator_version_min -sdk_version
After I updated my XCode Tool Chains
current version xcode-select version 2406
Rohan Maity
04/10/2024, 5:22 AMlinkDebugTestIosSimulatorArm64
I mean this is gradle task and kotlin is open source, so is there any place I can see where this task is written?Keith Karanu
04/14/2024, 5:08 PMstaticCFunction
not being allowed to have any non-global captures? I tried searching through YouTrack for issues that might discuss that, but I couldn't find any.Shekhar Shinde
04/15/2024, 8:56 AMHenri Gourvest
04/16/2024, 4:52 PMLucas Prioste
04/17/2024, 3:03 PMval formatter = DateTimeFormatter
.ofLocalizedDateTime(FormatStyle.LONG, FormatStyle.SHORT)
.withLocale(Locale.getDefault())
.withZone(ZoneId.systemDefault())
to format a LocalDateTime to a readable date, how can I remove the yearDenis Siprun
04/18/2024, 8:09 AMactual fun platform() = "Shared Linux X64"
actual fun triggerLambda(callback: () -> Unit) {
callback()
}
Next, in my C++ application, I added the corresponding libshared.a and libshared_api.h files. In these files, the functions I need have the following structure, I will only show a part of it:
typedef void* libshared_KNativePtr;
typedef struct {
libshared_KNativePtr pinned;
} libshared_kref_kotlin_Function0;
// irrelevant code skipped here
struct {
struct {
struct {
struct {
// irrelevant code skipped here
const char* (*platform)();
void (*triggerLambda)(libshared_kref_kotlin_Function0 callback);
} root;
} kotlin;
} libshared_ExportedSymbols;
extern libshared_ExportedSymbols* libshared_symbols(void);
So, in my application, I can easily call the first function, for example like this:
auto ktText = libshared_symbols()->kotlin.root.platform();
And it works.
But I am having trouble calling the second function:
class KotlinNativeVM: //...
void foo() {
// works
auto ktText = libshared_symbols()->kotlin.root.platform();
libshared_kref_kotlin_Function0 callback;
auto lambda = []() {
// ...
};
callback.pinned = reinterpret_cast<libshared_KNativePtr>(&lambda);
// The program crashes
libshared_symbols()->kotlin.root.triggerLambda(callback);
}
}
Because such call causing app to crash.Michal Havryluk
04/18/2024, 2:24 PMCherrio LLC
04/18/2024, 7:58 PMLuis Alonso Ato Neyra
04/19/2024, 10:01 PMNathan Bedell
04/23/2024, 3:01 PM@CName
annotation, that endpoint only gets exposed in the h file for the project itself.
What I mean by this is if I have some Kotlin native library Foo that has some @CName
declarations, and I have a Kotlin native project Bar that depends on Foo, ideally in the final built dll / so file I want to be able to still access the endpoints declares in Foo with @CName
.
However, what seems to happen right now is that only the @CName
declarations in Bar actually get exported as an external C function, and essentially if I want to have the ones from Foo available as well, I need to re-export them.
This isn't great for re-usability, so I was wondering if anyone has found a good workaround for this, or if this problem is known and being worked?
I've tried using both my final dll and the library dll in my final application, but that seems to cause other issues. I'm guessing because Bar is statically linked with Foo. So one thought I had was: Is it possible to get the Kotlin native compiler to dynamically link some Kotlin native library dependencies?Luis Alonso Ato Neyra
04/24/2024, 10:05 PMShekhar Shinde
04/25/2024, 11:00 AM