Page 1 of 2

[H] what is /MT?

Posted: 15 May 2019, 13:11
by swagfag
i just downloaded the latest h changes and there are some new folders _MT. whats the difference between the regular version and this one?
solved: see here and here

Re: [H] what is /MT?

Posted: 15 May 2019, 14:46
by kyuuuri
When compiling source code there are 2 options: /MD and /MT.
In the past AHK_H used /MD which means that the dll was not included in the exe, that's why you had to distribute vcruntime140.dll with your exe. Around 2 months ago (you can check on GitHub) HotKeyIt changed it to /MT which means that you do not need to distribute the dll with your exe.
There are pros and cons about this but you are free to compile with /MD if you want.

Re: [H] what is /MT?

Posted: 15 May 2019, 14:51
by swagfag
what pros and cons

Re: [H] what is /MT?

Posted: 15 May 2019, 15:17
by kyuuuri
/MD Pros:
  • The exe is smaller.
  • The dll is exposed to updates.
/MD Cons:
  • You need to distribute the dll with the exe.
  • If a dll is updated it might break your app.

/MT Pros:
  • You don't need to distribute the dll with the exe.
/MT Cons:
  • The exe is bigger.
    The Dll is not exposed to updates so if it needs to be updated you need to recompile the source.
Maybe there are more pros and cons but those are a few I know.

Re: [H] what is /MT?  Topic is solved

Posted: 15 May 2019, 16:06
by HotKeyIt
The most important difference is that MD will allow to modify/delete/create memory from dll in exe, exe in dll and dll in dll, where MT version it is very likely to cause memory leaks and will crash your program.
So when you don't use dll, MT version will be fine. Otherwise I would always use MD version!!!

Also MD version will use less memory when dll is used. https://social.msdn.microsoft.com/Forum ... um=msbuild

Re: [H] what is /MT?

Posted: 15 May 2019, 16:52
by swagfag
ok, so u cant use AhkThread(), for example, with /MT
thanks @kyuuuri and @HotKeyIt

Re: [H] what is /MT?

Posted: 16 May 2019, 10:47
by HotKeyIt
You can use it but best is not to manipulate memory of another thread!

Re: [H] what is /MT?

Posted: 16 May 2019, 12:07
by swagfag
"not manipulate the memory of another thread" in what way?

Re: [H] what is /MT?

Posted: 16 May 2019, 14:31
by HotKeyIt
Writing/Deleting/Allocation!

Re: [H] what is /MT?

Posted: 16 May 2019, 17:52
by kyuuuri
Does this include Critical Objects?

Re: [H] what is /MT?

Posted: 16 May 2019, 18:05
by swagfag
im sorry i dont understand what u mean by "Writing/Deleting/Allocation!". are u talking about the MemoryModule? are u talking about using getvar/assign from the main script on the thread script? are u talking about VarSetCapacity? that allocates memory.
are u talking about calling eg VirtualAlloc from the thread script or something?

Re: [H] what is /MT?

Posted: 16 May 2019, 18:39
by HotKeyIt
CriticalObject will most likely cause problems.
MemoryModule and getvar/assign will not cause problems.
The problem is internal memory allocation including VirtualAlloc, HeapAlloc...

Re: [H] what is /MT?

Posted: 16 May 2019, 19:08
by swagfag
ok thanks, i understand now

Re: [H] what is /MT?

Posted: 17 May 2019, 04:47
by kyuuuri
HotKeyIt wrote:
16 May 2019, 18:39
CriticalObject will most likely cause problems.
MemoryModule and getvar/assign will not cause problems.
The problem is internal memory allocation including VirtualAlloc, HeapAlloc...
Hello, have 2 questions:
What you said is true only for /MT right?

And, when using /MD is Critical Object the right way to share a variable for loops Like for example writing/reading to it every 20ms?
Or is there a more reliable / better / proper way to do this using HeapAlloc, VirtualAlloc, etc.?

Thank you.

Re: [H] what is /MT?

Posted: 17 May 2019, 04:53
by HotKeyIt
In MD Version you can use CriticalObject as much and as often as you like, it won't cause memory leaks and it is a fast + easy way to share data :+1:

Re: [H] what is /MT?

Posted: 17 May 2019, 05:03
by kyuuuri
HotKeyIt wrote:
17 May 2019, 04:53
In MD Version you can use CriticalObject as much and as often as you like, it won't cause memory leaks and it is a fast + easy way to share data :+1:
Nice! Thank you for answering and for everything you've done for ahk!

Re: [H] what is /MT?

Posted: 19 May 2019, 09:53
by Tomer
well, i'd rather use the MT version in my organisation cause many computers dont have vc_redist or have problem with it,
and therefore its causes scripts (complex programs) not to work at all.

but im afraid it will cause memory leaks and crashing...

dilemma...

Re: [H] what is /MT?

Posted: 19 May 2019, 16:15
by HotKeyIt
Why can't you save the vcruntime140.dll in the same folder where AHK_H.exe is? That is all you need to use MD version.

Re: [H] what is /MT?

Posted: 20 May 2019, 02:03
by Tomer
HotKeyIt wrote:
19 May 2019, 16:15
Why can't you save the vcruntime140.dll in the same folder where AHK_H.exe is? That is all you need to use MD version.
the vcruntime140.dll saved in the same folder where the AHK_H.exe is,
but It does not help in all cases.

In many cases its popup an error msg that "api-ms-win-crt-runtime-l1-1-0.dll is missing",
and when i copy this file separately to the pc then the error msg changed to "api-ms-win-crt-runtime-l1-1-0.dll is corrupted"

only installation of vc_redist or using the MT version instead solve this problem.

Re: [H] what is /MT?

Posted: 20 May 2019, 06:52
by kyuuuri
That never happened to me. Where did you get the dll from? Did you download it from those weird "download missing dlls" sites?
Also when this happens, can you calculate the hash of both (the one you use as original and the copy you distributed)?
If they are not different then there is a bug in ahk_h