2011-02-18 86 views
2

我尝试将应用程序写入我的Erlang程序。Erlang应用程序问题

我有test_app.erl:

-module(test_app). 

-behaviour(application). 

%% Application callbacks 
-export([start/2, stop/1]). 

start(_Type, _StartArgs) -> 
    test_sup:start_link(). 

stop(_State) -> 
    ok. 

和.app文件:

{application, test, 
    [{description, "test system."}, 
    {vsn, "1.0"}, 
    {modules, [test_app, test_sup, fsm]}, 
    {registered, [test_sup, fsm]}, 
    {applications, [kernel, stdlib]}, 
    {mod, {test_app, []}} 
]}. 

当我尝试启动应用程序:

application:start(test). 

我得到错误:

=INFO REPORT==== 18-Feb-2011::19:38:53 === 
    application: test 
    exited: {bad_return, 
       {{test_app,start,[normal,[]]}, 
       {'EXIT', 
        {undef, 
         [{test_sup,start_link,[[]]}, 
          {test_app,start,2}, 
          {application_master,start_it_old,4}]}}}} 
    type: temporary 
{error,{bad_return,{{test_app,start,[normal,[]]}, 
        {'EXIT',{undef,[{test_sup,start_link,[[]]}, 
            {test_app,start,2}, 
            {application_master,start_it_old,4}]}}}}} 

怎么了?我该如何解决它?

如果我作出ESHELL:

test_app:start(normal, []). 

比所有的作品。

谢谢。

+2

它告诉你函数`test_sup:start_link([])`不存在(`{test_sup,start_link,[[]]}`),但你用它来调用它`test_sup:start_link()`在你给我们的代码中。而且,你的.app文件显示模块`epmail_app`是你的应用程序清楚地以`test_app`开始时应该被调用的模块。有没有你没有正确发布的东西,或者我只是想象的东西? 如果是这样,Yasir的回复是正确的,关于返回值。 – 2011-02-18 13:59:40

回答

3

我想这可能是由不加载[正确] .beam引起的。确保所有模块都在同一个目录中,或者尝试使用-pa键到erl(1),例如, g .:

$ erl -pa ../ebin 
1> application:start(test). 
...