3
votes

I would like to write a standalone Erlang application which could be run just like any other program (by clicking on .exe executable). Something like Wings3D does.

How can I do it ? What is the best approach to make it possible ? I am on Windows platform, if it is important.

2nd UPDATE:

Well, I haven't exported the promodb:start/0 function and that was the reason Erlang could'n start (and, as the Muzaaya Joshua says, werl -s does not work). But now, I have another strange problem. In my rebar.config I have 2 dependencies:

{deps, [
            {cowboy, ".*", {git, "https://github.com/extend/cowboy.git"}},
            {erlydtl, ".*", {git, "https://github.com/evanmiller/erlydtl.git"}}
        ]
}.

and after I start Erlang using

erl -pa ebin deps/cowboy/ebin deps/erlydtl/ebin deps/proper/ebin -s promodb

I find by application:which_application() that only Cowboy is started:

[{cowboy,"Small, fast, modular HTTP server.","0.4.0"},
 {stdlib,"ERTS  CXC 138 10","1.18"},
 {kernel,"ERTS  CXC 138 10","2.15"}]

As far as I know, Erlang should start all needed applications that I put in my promodb.app file, as:

{application, promodb,
 [
    {description, ""},
    {vsn, "0.1"},
    {registered, [promodb_sup]},
    {applications, [
                  kernel,
                  stdlib,
                  cowboy,
                  erlydtl
                 ]},
    {mod, { promodb, []}},
    {env, []}
 ]}.

What did I do wrong ?

4
There's a similar question: stackoverflow.com/questions/1795628/… It has a link to this guide that may help you: sics.se/~joe/sae.html - mqsoh
Thank you for that link, I've seen it already. Doesn't help much since its development stopped. But as you see, I have another, much simpler problem stil unresolved: how to start Erlang with arbitrary application on Windows ? - Radek

4 Answers

3
votes

I use rebar escriptize to pack a standalone package like rebar. Then you can use ./PackageName in linux or escript.exe PackageName in windows.

2
votes

I think you need to create a release package and a boot script as explained in the documentation.

1
votes

Actually the -s option works everywhere. Just use erl NOT werl. The werl command attempts to load a GUI on Windows.

The BitRock Install Builder is a great tool you need to check out. Yaws Web Server written in Erlang, uses it and many other applications.

1
votes

Erlydtl doesn't have an application behaviour, it works like a library. As you can see in erlydtl examples, no app is needed to be started.

https://github.com/evanmiller/erlydtl#template-compilation

Check this:

erl -pa ebin deps/*/ebin

1> erlydtl:compile(<<"{{ foo }}">>, my_module_name).

Does it works?

I like escriptize rebar option to create executables.