[erlang-questions] How to build Erlang with libcmt (/MT) under windows?

Michael Regen <>
Sun Oct 19 13:30:54 CEST 2008


Hi Björn,

I can understand that you do not have intentions supporting it in the main
distribution. It simply does not make sense there. An installer is needed in
any case which can take care of the CRT dependencies.

But may I ask you - can you give me a hint where Microsoft discourages the
use of a statically bound CRT? Or give me a hint why that would lead to
memory leaks? I would really like to understand the problem, investigated
since I read your statements and so far was unsuccessful finding any hints.

The reason why I am asking is because I was thinking about some kind of SAE
revival. I wrote some tests and I am already able to run Erlang together
with many kinds of Erlang applications in one single .exe without patching
the emulator.

But of course this does not make sense if there are dependencies to one of
the bazillion msvcr??.dlls out there. Furthermore more recent CRTs cannot be
loaded with LoadLibrary or similar mechanisms and my solution needs that.

In case someone is curious: I kind of rewrote erl.c, erlexec.c and
win_erlexec.c. It hooks some of its own API calls (e.g. file I/O) and serves
files (e.g. .beam, .dll, etc.) out of a zip file attached to the .exe. In
some aspects it is similar to py2exe. I am pretty sure such a solution would
be nice to have. Not for your super stable high-performance server
applications but for lots of smaller tools.

I will publish the code as soon as it is out of pre-alpha - if the concept
makes sense.

Thank you!

Regards,
Michael

On Fri, Oct 17, 2008 at 11:12 AM, Bjorn Gustavsson <>wrote:

> 2008/10/5 Michael Regen <>
>
>> Hi,
>>
>> Does anyone a little bit more experienced with the Erlang build mechanism
>> know how to compile and link Erlang with libcmt instead of msvcrt?
>> The default mechanism builds Erlang with the /MD switch which means the C
>> standard libraries are accessed as threaded dll MSVCR??.DLL. This also means
>> you cannot simply copy Erlang to another computer as long as the correct C
>> runtime is not installed there.
>>
>> I am trying to figure out how to statically bind the libcmt library.
>> Normally you do this by using the /MT switch.
>>
>
> Sorry, but we have no intention of supporting that. The reason is that
> Microsoft strongly discourages using the statically linked run-time library
> in programs
> that loads DLLs. Having a MT-linked emulator will lead to memory leaks.
>
> /Bjorn
> --
> Björn Gustavsson, Erlang/OTP, Ericsson AB
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20081019/ff353c7a/attachment.html>


More information about the erlang-questions mailing list