Erlang:将库添加到应用程序 [英] Erlang: add libraries to application

查看:124
本文介绍了Erlang:将库添加到应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 erlIDE (基于Eclipse)来处理Erlang项目。到今天一切都很好,但今天我必须在我的应用程序中使用外部库(couchbeam)。我发现,什么是地狱,btw。)



问题很简单 - 我不能将外部库包含到编译器路径中。我使用钢筋来获得沙发的依赖,它也下载了ibrowse,mochiweb和ejson。



如何将这些库包含在编译器路径中,而不会修改ERL_LIBS在erlIDE工作项目?



我不想修改ERL_LIBS,因为我可以更改项目的路径,启动新的路径(然后我应该再次修改ERL_LIBS)等等。



我在erlIDE中尝试过编译器选项:

  {pa,{pa,'site_stater / deps / couchbeam /'}} 



  {pa,{pa,'../deps/couchbeam/'}} 

其中'site_stater' - 是项目名称



我想知道如何专业的erlang程序员组织他们的项目工作流程(他们编写erlang程序,调试它,处理外部库等)。



非常感谢您的关注。 / p>

更新
我写了简单的函数来加载库,但我认为处理这个问题仍然是错误的方法:

  load_libraries() - > 
ProjectRoot = filename:join([filename:absname(./),site_stater]),
{ok,DepsList} = file:list_dir(ProjectRoot ++/ deps /) ,
列表:foreach(fun(Folder))>
RealFolder = ProjectRoot ++/ deps /++文件夹,
案例filelib:is_dir(RealFolder)
true - >
code:add_patha(filename:join([RealFolder,/ ebin]));
false - > ok
end
end,
DepsList),
ok。


解决方案

我现在无法验证,但是应该能够在编译器选项中使用 {pa,'../ deps / couchbeam /'} 。如果这不行,请尝试使用绝对路径。



编译器设置尚未完成,我们计划使用一些简单的方式来引用外部库,我们还没有每个用户的这种查询都增加了修复它的重要性!



regards,
Vlad


I use erlIDE (based on Eclipse) to work on Erlang projects. Till today everything was fine, but today I have to use external library (couchbeam) in my application. I found out, what is hell, btw.)

The problem is simple – I cannot include external library to compiler path. I've used rebar to get couchbeam's dependencies and it also downloaded ibrowse, mochiweb and ejson.

How can I include those libraries to compiler path without modifing ERL_LIBS to work on project in erlIDE?

I do not want modify ERL_LIBS, because I can change projects's path, start new one (then I should modify ERL_LIBS again) and so on.

I've tried compiler options in erlIDE:

{pa, {pa, 'site_stater/deps/couchbeam/'}}

or

{pa, {pa, '../deps/couchbeam/'}}

where 'site_stater' – is project's name

I wonder how professional erlang programmers organaze their projects workflow (where they write erlang progs, how debuggin it, deal with external libraries and so on).

Many thanks for your attension.

UPDATE I wrote simple function to load libraries, but I think it is still wrong way to deal with this problem:

load_libraries() ->
    ProjectRoot = filename:join([filename:absname("./"), "site_stater"]),
    {ok, DepsList} = file:list_dir(ProjectRoot ++ "/deps/"),
    lists:foreach(fun (Folder) ->
                       RealFolder = ProjectRoot ++ "/deps/" ++ Folder,
                       case filelib:is_dir(RealFolder) of
                           true ->
                               code:add_patha(filename:join([RealFolder, "/ebin"]));
                           false -> ok
                       end
                  end,
                DepsList),
    ok.

解决方案

I can't verify it right now, but you should be able to use {pa, '../deps/couchbeam/'} in the compiler options. If that doesn't work, please try using an absolute path.

The compiler settings are not finished yet, we plan to have some simpler way to refer to external libraries but we're not there yet. Every such query from users increases the importance of fixing it!

regards, Vlad

这篇关于Erlang:将库添加到应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆