https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
b

basher

03/24/2019, 2:35 AM
I'm trying to call a function from the windows platform libraries:
BCryptGenRandom
. At link time, I get
undefined reference to 'BCryptGenRandom'
. Here are the linker settings I have for my mingw test target:
Copy code
targetFromPreset(presets.mingwX64, 'mingw') {
    compilations.test.linkerOpts '-Wl,--subsystem,windows,-L"C:\\Program Files (x86)\\Windows Kits\\10\\Lib\\10.0.17763.0\\um\\x64\\bcrypt.lib"'
}
I think I may have overdone it with the full path to bcrypt.lib there, but I'm trying everything. Any advice here would be appreciated! First time attempting to get my K/N code working for mingw. Thanks!
i've also tried just
compilations.test.linkerOpts '-Wl,--subsystem,windows
to match the win32 example in the K/N repo
m

msink

03/24/2019, 5:36 AM
Mingw is not compatible with with libs in msvc format, please use libs from msys2-mingw64 distribution.
b

basher

03/24/2019, 6:13 AM
Ah! I’ll give that a try. Thanks!
o

olonho

03/24/2019, 3:37 PM
no need to use lib file here, just
-lbcrypt
in linker options works for me. Technically, it’s a bug in platform libs, so we’ll fix it in upcoming releases.
b

basher

03/24/2019, 3:40 PM
Thanks I was just about to update that I got it working this way:
compilations.test.linkerOpts "-Wl,--subsystem,windows, -Bstatic -lbcrypt"
. I also happened to have just installed msys2 and the associated mingw-w64-x86_64-toolchain (installs the platform libs to
"C:\msys64\mingw64\lib"
). Did I need that, or would
-lbcrypt
have worked without installing those libs?
Also, is there a ticket I can follow for the bug?
no need to install anything
b

basher

03/24/2019, 3:43 PM
Ha! It's literally just bcrypt. Thanks for all of that!