Search code examples
erlangreleaserebar3

Erlang: How to include wx libraries in rebar3 release


How do I include the wx libraries, that are shipped with erlang (/lib/erlang/lib/wx-2.1.2), in my rebar3 release? I do not understand where to copy those files and how to declare them in my rebar.config file.

I use this code in my app:

-module(main_window).
-include_lib("wx/include/wx.hrl").
-include("state_records.hrl").
-export([start/0]).

start() ->
    Wx = wx:new(),
    State = wx:batch(fun() -> create_window(Wx) end),
    wxWindow:show(State#state.frame),
    loop(State),
    wx:destroy(),
    ok.

...

Starting my app by running rebar3 compile and then rebar3 shell works. But when I use rebar3 release I get the following output:

===> There are missing function calls in the release.
===> Make sure all applications needed at runtime are included in the release.
===> main_window:create_window/1 calls undefined function wxBoxSizer:new/1
===> main_window:create_window/1 calls undefined function wxFrame:connect/2
===> main_window:create_window/1 calls undefined function wxFrame:createStatusBar/2
===> main_window:create_window/1 calls undefined function wxFrame:new/4
===> main_window:create_window/1 calls undefined function wxFrame:setIcon/2
===> main_window:create_window/1 calls undefined function wxFrame:setMenuBar/2
===> main_window:create_window/1 calls undefined function wxFrame:setStatusText/3
===> main_window:create_window/1 calls undefined function wxIcon:new/2
...

Solution

  • According to the documentation here applications that relx will add into release should be mentioned as a list see <app>.

    Running rebar3 release will build the release and provide a script for starting a node under _build//rel//bin/.

    <release_name> must be an atom, same for each in the list of applications to include in the release.

    {relx, [{release, {<release name>, <vsn>},
         [<app>]},
    
        {dev_mode, true},
        {include_erts, false},
    
        {extended_start_script, true}]}.