Re: Reference to an unresolved external symbol

2022-09-07 Thread Injeckt via Digitalmars-d-learn

On Wednesday, 7 September 2022 at 10:50:17 UTC, Dennis wrote:

On Wednesday, 7 September 2022 at 10:14:22 UTC, Injeckt wrote:
I guess you right. But I don't know how i gonna link libs when 
I'm using "dmd main.d".


Another way is to add this to your code:

```D
pragma(lib, "User32");
```


Oh thank you. I didn't knew that, I thought that it only works in 
visual studio.
Comrades, I need to use inet_ntop() from Ws2tcpip.h, but how I 
gonna include this header file to my code file?


Re: Reference to an unresolved external symbol

2022-09-07 Thread Dennis via Digitalmars-d-learn

On Wednesday, 7 September 2022 at 10:14:22 UTC, Injeckt wrote:
I guess you right. But I don't know how i gonna link libs when 
I'm using "dmd main.d".


Another way is to add this to your code:

```D
pragma(lib, "User32");
```




Re: Reference to an unresolved external symbol

2022-09-07 Thread Injeckt via Digitalmars-d-learn
On Wednesday, 7 September 2022 at 10:31:02 UTC, rikki cattermole 
wrote:


On 07/09/2022 10:14 PM, Injeckt wrote:
On Wednesday, 7 September 2022 at 10:01:11 UTC, rikki 
cattermole wrote:


You have probably forgotten to link against user32.


I guess you right. But I don't know how i gonna link libs when 
I'm using "dmd main.d". Tell me please.


I think it is as simple as adding user32.lib to dmd (directly).


LOL! WTF?!? It works! Thanks Sensei.


Re: Reference to an unresolved external symbol

2022-09-07 Thread rikki cattermole via Digitalmars-d-learn



On 07/09/2022 10:14 PM, Injeckt wrote:

On Wednesday, 7 September 2022 at 10:01:11 UTC, rikki cattermole wrote:


You have probably forgotten to link against user32.


I guess you right. But I don't know how i gonna link libs when I'm using 
"dmd main.d". Tell me please.


I think it is as simple as adding user32.lib to dmd (directly).


Re: Reference to an unresolved external symbol

2022-09-07 Thread Injeckt via Digitalmars-d-learn
On Wednesday, 7 September 2022 at 10:01:11 UTC, rikki cattermole 
wrote:


You have probably forgotten to link against user32.


I guess you right. But I don't know how i gonna link libs when 
I'm using "dmd main.d". Tell me please.


Re: Reference to an unresolved external symbol

2022-09-07 Thread rikki cattermole via Digitalmars-d-learn



You have probably forgotten to link against user32.


Reference to an unresolved external symbol

2022-09-07 Thread Injeckt via Digitalmars-d-learn
Hi guys, I have an issue when I compile program with using 
windows api, I got this message:
"reference to an unresolved external symbol _MessageBoxW@16". I 
just created simple hello world using winapi and MessageBox.


import core.runtime;
import std.stdio;
import std.string;
import core.sys.windows.windows;

extern(Windows)
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, 
LPSTR cmdLine, int nCmdShow) {

int result;

try {
Runtime.initialize();
result = myWinMain(hInstance, hPrevInstance, cmdLine, 
nCmdShow);

Runtime.terminate();
} catch (Throwable e) {
result = 0;
}

return result;
}

int myWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, 
LPSTR cmdLine, int nCmdShow) {

MessageBox(null, "Hello", "D!", MB_OK);

return 0;
}