I'm confused about how Platform Library implementa...
# kotlin-native
i
I'm confused about how Platform Library implementations are linked by the compiler. kodee lost From the docs: > The packages from platform libraries are available by default. You don't need to specify additional link options to use them. The Kotlin/Native compiler automatically detects which platform libraries are accessed and links the necessary ones. That doesn't match my experience on Windows using platform.windows. When I import and use the bindings for some Win32 APIs, I get link errors when building my test binaries:
ld.lld: error: undefined symbol: <name of symbol>
. The problem goes away if I specify
-lversion
as a linker argument. The specific APIs are GetFileVersionInfoSizeW, GetFileVersionInfoW, and VerQueryValueW, all of which are declared in *winver.h*, which is included in *windows.h*, which is specified as one of the headers bound in the *platform.windows* DEF file. Why aren't the platform library implementations properly automatically linked by the compiler?
FWIW, I'm using other Windows APIs (e.g., getaddrinfo) just fine. The compiler successfully links the platform implementation with no additional linker args.
🐞🤔 Is this possibly a bug? Should
-lversion
be included in the *windows.def* file?
Found KT-46380 which describes the issue but it's closed and merely shows the workaround of manually setting linker options.
p
do you have examples of successfully using native mingw64? there is almost no samples....
i
Yes, I can probably point you to some examples. What're you looking for specifically?
p
Window management, interop with windows apis (can local windows apis be used?) and just simple mini examples would be useful to familiarize myself with the apis