How do you compile an Erlang program into a standalone windows executable?

一笑奈何 提交于 2019-12-20 09:14:21

问题


Richard of Last.fm over at metabrew has ported his apps to Erlang. It was also done by riak, couchdb and others. He mentions extracting the needed parts, or including the whole VM into the distribution. Main trait here is: the program does not require Erlang to be installed on the target machine.

So the question is, how do you, step by step, package an Erlang program into a windows (and, less important, linux) executable?

P.S. I've seen the SAE project, and I've read all the relevant questions here. None answer my question.


回答1:


  1. Create a portable version of Erlang (for example using method from this discussion group: Erlang on Windows from USB). The most important part in this exercise is the creation of the erl.ini file with correct paths which can be used to start Erlang from any desired location.
  2. Create an Erlang release of your application and the release boot script. For instructions see Erlang documentation about releases.
  3. Create a Windows command line script to boot your application. This will simply run Erlang with your boot script as the parameter (e.g. erl -boot someapp). Erlang will read the erl.ini file to load your application and system libraries from correct locations.
  4. Create a Windows setup application with all the relevant parts packaged in:
    • the Erlang distribution
    • the erl.ini file with all the paths as variables to be filled in by the setup application
    • the release of your application (all the beam files and the boot script)
    • the command line script to boot the application using the boot script

How it should work from the Windows installer point of view:

  • Ask user where to install the application (or use some default location in Program Files)
  • Copy the Erlang distribution, your application and the boot script to the correct location
  • Update erl.ini and the command line script to use the chosen location
  • Create icons or autostart entries that will execute the command line script

Now when user clicks the icon or executes the command line script in another way they will in fact run Erlang from the custom location, which in turn will boot your application according to the Erlang boot script. This is just a general idea because the command line script should for example check if Erlang isn't already running when user starts the application for the second time, or it may need to be able to uninstall it.




回答2:


Maybe this answer you question - https://github.com/dgud/wings/blob/master/BUILD.win32



来源:https://stackoverflow.com/questions/11796941/how-do-you-compile-an-erlang-program-into-a-standalone-windows-executable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!