# Kotlin: Unresolved reference: win32

**URL:** <https://discuss.kotlinlang.org/t/kotlin-unresolved-reference-win32/7052>\
**Category:** Uncategorized\
**Created:** [March 14, 2018, 3:34pm UTC](https://discuss.kotlinlang.org/t/kotlin-unresolved-reference-win32/7052 "2018-03-14T15:34:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![SL5](https://avatars.discourse-cdn.com/v4/letter/s/f05b48/32.png) [@SL5](https://discuss.kotlinlang.org/u/SL5)\
**Post date:** [March 14, 2018, 3:34pm UTC](https://discuss.kotlinlang.org/t/kotlin-unresolved-reference-win32/7052/1 "2018-03-14T15:34:30Z")

</div>

hi 🙂 i dont understand this error. i using idea from jetbains. may you could help. thanks

```
import win32.*
fun main(args: Array) {
  println("Hello, World!")
  MessageBoxW(null, "hi!","ho", MB_YESNOCANCEL or MB_ICONQUESTION)
}
```

IntelliJ IDEA 2017.3.4 (Ultimate Edition)  
Build #IU-173.4548.28, built on January 29, 2018  
JRE: 1.8.0\_152-release-1024-b11 amd64  
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o  
Windows 10 10.0

---

<div class="post-metadata">

**Author:** ![Wasabi375](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/wasabi375/32/4741_2.png) [@Wasabi375](https://discuss.kotlinlang.org/u/Wasabi375)\
**Post date:** [March 14, 2018, 7:54pm UTC](https://discuss.kotlinlang.org/t/kotlin-unresolved-reference-win32/7052/2 "2018-03-14T19:54:26Z")

</div>

Which library are you trying to load win32 from? Did you add it to your dependencies? As far as I know there is no win32 package in java.

Also `MessageBoxW` sounds like you are trying to access c++ code from within Kotlin. Correct me if I’m wrong.

---

<div class="post-metadata">

**Author:** ![SL5](https://avatars.discourse-cdn.com/v4/letter/s/f05b48/32.png) [@SL5](https://discuss.kotlinlang.org/u/SL5)\
**Post date:** [March 14, 2018, 8:32pm UTC](https://discuss.kotlinlang.org/t/kotlin-unresolved-reference-win32/7052/3 "2018-03-14T20:32:43Z")

</div>

> [@Wasabi375](#):
>
> Which library are you trying to load win32 from? Did you add it to your dependencies? As far as I know there is no win32 package in java.
> 
> Also MessageBoxW sounds like you are trying to access c++ code from within Kotlin. Correct me if I’m wrong.

Later i downloadet this and tried to move it into “External Libraries” folder:  
[https://download-cf.jetbrains.com/kotlin/native/kotlin-native-windows-0.3.zip](https://download-cf.jetbrains.com/kotlin/native/kotlin-native-windows-0.3.zip)  
It could not be added. Sorry, I should have added this info earlier, I was distracted.

The source example i got from here:

> **[Kotlin/Native v0.3 is out | The Kotlin Blog](https://blog.jetbrains.com/kotlin/2017/06/kotlinnative-v0-3-is-out/)**
>
> We're happy to announce the release of Kotlin/Native v0.3. We are going to the new lands! With the release of version v0.3 Windows is supported as both a compilation host and execution target, and Goo

I dont know if MessageBoxW is c++ code. If yes it will surprices me.

---

<div class="post-metadata">

**Author:** ![SackCastellon](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/sackcastellon/32/4553_2.png) [@SackCastellon](https://discuss.kotlinlang.org/u/SackCastellon)\
**Post date:** [March 14, 2018, 9:02pm UTC](https://discuss.kotlinlang.org/t/kotlin-unresolved-reference-win32/7052/4 "2018-03-14T21:02:07Z")

</div>

I am not really sure if Kotlin Native is supported by IntelliJ, try using CLion.

> **[Kotlin/Native IDE Support Preview | The Kotlin Blog](https://blog.jetbrains.com/kotlin/2017/11/kotlinnative-ide-support-preview/)**
>
> Kotlin/Native is a brand new technology that compiles Kotlin directly to machine code and produces executables that can run without a virtual machine. At KotlinConf 2017, we announced a preview releas

---

<div class="post-metadata">

**Author:** ![Wasabi375](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/wasabi375/32/4741_2.png) [@Wasabi375](https://discuss.kotlinlang.org/u/Wasabi375)\
**Post date:** [March 14, 2018, 9:39pm UTC](https://discuss.kotlinlang.org/t/kotlin-unresolved-reference-win32/7052/5 "2018-03-14T21:39:46Z")

</div>

If I understand the native support correctly CLion is the official Editor for Kotlin Native. There is also a gradle plugin but CLion does not support gradle. So the state of Kotlin Native support is kind of strange right now.

But I think the problem @SL5 is having is that he is trying to use a Kotlin Native library in a Kotlin JVM build, which is not possible. I am 99% sure `MessageBoxW` is the wrapper for the unicode version of [MessageBox function (winuser.h) - Win32 apps | Microsoft Docs](https://msdn.microsoft.com/en-us/library/windows/desktop/ms645505(v=vs.85).aspx)

Looking at the win32 sample in the zip file, I am now 100% sure. In there, there is a win32.def file importing the headers to `windows.h` which contains `MessageBoxW` function.

As to fixing this, either try using CLion and do a Kotlin Native build. You will also specify the win32.def as seen in the example or use the java libraries to create the message box: [How to Make Dialogs (The Java™ Tutorials \> Creating a GUI With Swing \> Using Swing Components)](https://docs.oracle.com/javase/tutorial/uiswing/components/dialog.html)
