English 中文(简体)
Erlang compilation - Erlang as stand alone executeable
原标题:

is there a way to compile Erlang to be a stand-alone executable? this means, to run it as an exe without the Erlang runtime.

问题回答

While it s possible to wrap everything up in a single EXE, you re not going to get away from having an Erlang runtime. Dynamic languages like Erlang can t really be compiled to native x86 code, for instance, due to their nature. There has to be an interpreter in there somewhere.

It s possible to come up with a scheme that bundles the interpreter and all the BEAM files into a single EXE you can double-click and run directly, but that s probably more work than you were wanting to go to. I ve seen it done before, but there s rarely a good reason to do it, so I won t bother going into detail on the techniques here.

Instead, I suggest you use the same technique they use for Python s py2exe and py2app programs for creating Windows and Mac OS X executables, respectively. These programs load the program s main module up into a Python interpreter, figure out which other modules it needs using the language s built-in reflection mechanisms, then write out all those compiled modules along with a copy of the language interpreter and a small wrapper program that launches the program s main module with the interpreter. The directory containing those files is then a stand-alone environment, having everything needed to run the program. The only difference in the Erlang case is that python.exe becomes erl.exe, and *.pyc becomes *.beam. The basic idea is still the same.

You can simplify this if you don t need it to work with any arbitrary Erlang program, but only yours. In that case, you just copy the Erlang interpreter and all the .beam files that make up your program into a single directory. You can make this part of your program s Makefile, for instance.

You can then use your favorite setup.exe or MSI creation method for creating a distributable package that installs this collection of files into c:Program FilesMyProgram on the end user s system and creates a shortcut for "erl mainmodule.beam" in their Start menu. The end user doesn t care that as part of the program they also get a copy of Erlang. That s an implementation detail.

you can use Warp. I ve added examples for wrapping an Erlang release.





相关问题
java in-memory on-the-fly class compilation (and loading)

I want to revisit an old question of mine about in-memory "compilation" of classes. Since about 1/2 a year have passed since I asked (and was somewhat answered), I d like to re-raise the issue and see ...

(c)make - resursive compile

Let s assume I have directories like: dir1 main.cpp dir2 abc.cpp dir3 def.cpp dir4 ghi.cpp jkl.cpp And let s assume that main.cpp ...

How to link to a static library in C?

I use code::blocks to compile my static library. The output result is a libstatic.a file. Now, how do I link to my library to use functions that were compiled? (I tried to use #include "libstatic.a"...

Statically linking Winsock?

I m using Winsock 1.1 in my project. I include wsock32.lib in "Additional Dependencies". I m looking at the DLL project using depends.exe and notice that the DLL depends on wsock32.dll. How can I ...

热门标签