www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - MessageBoxA linking error

reply bauss <jacobbauss gmail.com> writes:
Whenever I try to use MessageBoxA then I get a linking error that 
the symbol cannot be found.

I am importing core.sys.windows.windows.

What else am I missing?

The exact error:

```
lld-link: error: undefined symbol: MessageBoxA
 referenced by ...\source\client\source\main.d:24
               
 ...\~master\build\application-debug-FMqG_QyKCCZMqpWApQaoww\....obj:(WinMain)
Error: linker exited with status 1 ```
Dec 11 2024
parent reply Ferhat =?UTF-8?B?S3VydHVsbXXFnw==?= <aferust gmail.com> writes:
On Wednesday, 11 December 2024 at 11:22:09 UTC, bauss wrote:
 Whenever I try to use MessageBoxA then I get a linking error 
 that the symbol cannot be found.

 I am importing core.sys.windows.windows.

 What else am I missing?

 The exact error:

 ```
 lld-link: error: undefined symbol: MessageBoxA
 referenced by ...\source\client\source\main.d:24
               
 ...\~master\build\application-debug-FMqG_QyKCCZMqpWApQaoww\....obj:(WinMain)
Error: linker exited with status 1 ```
I have no idea whether it should be automatically linked with it, but it requires User32.lib pragma(lib, "user32"); should work, otherwise it must be provided via linker flags. https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-messageboxa
Dec 11 2024
parent bauss <jacobbauss gmail.com> writes:
On Wednesday, 11 December 2024 at 11:32:44 UTC, Ferhat Kurtulmuş 
wrote:
 On Wednesday, 11 December 2024 at 11:22:09 UTC, bauss wrote:
 Whenever I try to use MessageBoxA then I get a linking error 
 that the symbol cannot be found.

 I am importing core.sys.windows.windows.

 What else am I missing?

 The exact error:

 ```
 lld-link: error: undefined symbol: MessageBoxA
 referenced by ...\source\client\source\main.d:24
               
 ...\~master\build\application-debug-FMqG_QyKCCZMqpWApQaoww\....obj:(WinMain)
Error: linker exited with status 1 ```
I have no idea whether it should be automatically linked with it, but it requires User32.lib pragma(lib, "user32"); should work, otherwise it must be provided via linker flags. https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-messageboxa
pragma(lib, "user32") worked. Thank you.
Dec 11 2024