[H] what is /MT? Topic is solved

Ask for help, how to use AHK_H, etc.
swagfag
Posts: 2830
Joined: 11 Jan 2017, 17:59

[H] what is /MT?

15 May 2019, 13:11

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
Last edited by swagfag on 16 May 2019, 19:08, edited 1 time in total.
kyuuuri
Posts: 206
Joined: 09 Jan 2016, 19:20

Re: [H] what is /MT?

15 May 2019, 14:46

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.
swagfag
Posts: 2830
Joined: 11 Jan 2017, 17:59

Re: [H] what is /MT?

15 May 2019, 14:51

what pros and cons
kyuuuri
Posts: 206
Joined: 09 Jan 2016, 19:20

Re: [H] what is /MT?

15 May 2019, 15:17

/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.
HotKeyIt
Posts: 1866
Joined: 29 Sep 2013, 18:35
Contact:

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

15 May 2019, 16:06

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
swagfag
Posts: 2830
Joined: 11 Jan 2017, 17:59

Re: [H] what is /MT?

15 May 2019, 16:52

ok, so u cant use AhkThread(), for example, with /MT
thanks @kyuuuri and @HotKeyIt
HotKeyIt
Posts: 1866
Joined: 29 Sep 2013, 18:35
Contact:

Re: [H] what is /MT?

16 May 2019, 10:47

You can use it but best is not to manipulate memory of another thread!
swagfag
Posts: 2830
Joined: 11 Jan 2017, 17:59

Re: [H] what is /MT?

16 May 2019, 12:07

"not manipulate the memory of another thread" in what way?
kyuuuri
Posts: 206
Joined: 09 Jan 2016, 19:20

Re: [H] what is /MT?

16 May 2019, 17:52

Does this include Critical Objects?
swagfag
Posts: 2830
Joined: 11 Jan 2017, 17:59

Re: [H] what is /MT?

16 May 2019, 18:05

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?
HotKeyIt
Posts: 1866
Joined: 29 Sep 2013, 18:35
Contact:

Re: [H] what is /MT?

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...
swagfag
Posts: 2830
Joined: 11 Jan 2017, 17:59

Re: [H] what is /MT?

16 May 2019, 19:08

ok thanks, i understand now
kyuuuri
Posts: 206
Joined: 09 Jan 2016, 19:20

Re: [H] what is /MT?

17 May 2019, 04:47

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.
HotKeyIt
Posts: 1866
Joined: 29 Sep 2013, 18:35
Contact:

Re: [H] what is /MT?

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:
kyuuuri
Posts: 206
Joined: 09 Jan 2016, 19:20

Re: [H] what is /MT?

17 May 2019, 05:03

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!
User avatar
Tomer
Posts: 282
Joined: 21 Aug 2016, 05:11

Re: [H] what is /MT?

19 May 2019, 09:53

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...
HotKeyIt
Posts: 1866
Joined: 29 Sep 2013, 18:35
Contact:

Re: [H] what is /MT?

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.
User avatar
Tomer
Posts: 282
Joined: 21 Aug 2016, 05:11

Re: [H] what is /MT?

20 May 2019, 02:03

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.
kyuuuri
Posts: 206
Joined: 09 Jan 2016, 19:20

Re: [H] what is /MT?

20 May 2019, 06:52

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

Return to “Ask For Help”

Who is online

Users browsing this forum: No registered users and 4 guests