This is now no longer a problem with the lib but m...
# kotlin-native
a
This is now no longer a problem with the lib but my own problem that I would like to solve for future reference. When linking with the original dll it compiles and links just fine
m
Don't know how you compile, but typical extension for static lib compiled by msys2-mingw64 is
.a
, not
.lib
. See https://github.com/msink/kotlin-libui/blob/master/libui/src/nativeInterop/cinterop/libui.def#L5
a
I'm using a shared library. I only followed the kn docs and the libs build instructions here: https://github.com/signal11/hidapi
The kln docs say that all libs, even static libs, on windows need to be .lib
m
You mean "To build HIDAPI using MinGW or Cygwin using Autotools, use the instructions in the section titled "Building HIDAPI into a shared library on Unix Platforms" above."? Ok, cloned to f:\src, then in msys2-mingw64 console:
Copy code
cd /f/src/hidapi
./bootstrap
./configure
make
make install
Got
libhidapi.a
and
libhidapi.dll.a
in
msys64\mingw64\lib
directory.
a
Yeah that's actually where I get stuck I guess. Not sure how to run those scripts on windows
But I'll take that question elsewhere since this is a kotlin native channel not a HIDAPI channel
m
Well - if as you said K/N documentation mentiod somewhere that libs on Windows should be
.lib
- it's K/N documentation bug.
a
Yeah that is also true. It says all libs, static or dynamic, should be of .lib
s
What does compiler error look like? Could you share it?
a
Copy code
C:\Users\Alex\Desktop\hidstuff>kotlinc-native -g src/*.kt -l out/cinterop/hidapi.klib -linker-options "libs\hidapi\hidapi.lib"
C:\Users\Alex\AppData\Local\Temp\konan_temp2160950149983819903\combined.o:(.text+0x29285): undefined reference to `hid_init'
C:\Users\Alex\AppData\Local\Temp\konan_temp2160950149983819903\combined.o:C:\BuildAgent\work\4d622a065c544371\runtime\src\main\kotlin\kotlin\text\regex\sets/DecomposedCharSet.kt:50: undefined reference to `hid_exit'
C:\Users\Alex\AppData\Local\Temp\konan_temp2160950149983819903\combined.o:C:\BuildAgent\work\4d622a065c544371\runtime\src\main\kotlin\kotlin\text\regex\sets/DecomposedCharSet.kt:50: undefined reference to `hid_enumerate'
C:\Users\Alex\AppData\Local\Temp\konan_temp2160950149983819903\combined.o:C:\BuildAgent\work\4d622a065c544371\runtime\src\main\kotlin\kotlin\text\regex\sets/DecomposedCharSet.kt:50: undefined reference to `hid_open_path'
C:\Users\Alex\AppData\Local\Temp\konan_temp2160950149983819903\combined.o:C:\BuildAgent\work\4d622a065c544371\runtime\src\main\kotlin\kotlin\text\regex\sets/DecomposedCharSet.kt:50: undefined reference to `hid_close'
clang++.exe: error: linker command failed with exit code 1 (use -v to see invocation)
error: c:\Users\Alex\.konan\dependencies\msys2-mingw-w64-x86_64-gcc-7.3.0-clang-llvm-lld-6.0.1/bin/clang++ invocation reported errors
And the .lib is also in the same location as my .exe output
m
If you compiled by MSVC - of cource K/N don't see it.
a
Yeah that's what I was thinking actually. I'm still pretty new to the whole compilers and linker stuff. But I'll figure it out at some point.