如何使用 erlang-examples
我刚刚使用 apt-get
将 Erlang 下载到 Ubuntu 10.10 上。如何运行 Erlang 附带的示例(可以通过 apt-get install erlang-examples 获得的示例)。我尝试进入它们存储的目录并编译ball.erl,但出现以下错误:
ball.bea#: error writing file
error
I just downloaded Erlang using apt-get
onto Ubuntu 10.10. How do I run the examples that come with Erlang (the examples you can get through apt-get install erlang-examples
). I tried going to the directory where they were stored and compiling ball.erl
, but I got this error:
ball.bea#: error writing file
error
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
普通用户无法写入存储这些示例的目录。要编译
.erl
文件,编译器需要能够写出编译后的.beam
文件。解决此问题的一种方法是将文件复制到您可以写入的目录并在那里编译它们:
您需要安装
erlang-dev
包才能工作。您可以像这样运行
ball
示例:ball
这里是模块名称,Erlang 模拟器默认调用start/0
函数该模块,在本例中是正确的。然而,您实际上不必编译这些示例。 Ubuntu
erlang-examples
软件包附带已编译的它们:关闭每个中的 GUI 窗口后,说
q().
以退出模拟器。这对你来说可能看起来很奇怪,直到你意识到 Erlang 的一切都是为了长时间的正常运行而设计的。模拟器运行的最后一个进程已停止这一事实不足以让 BEAM 模拟器自行关闭。毕竟,稍后可能会在同一个模拟器中启动其他东西。The directory where those examples are stored isn't writeable by normal users. To compile a
.erl
file, the compiler needs to be able to write out the compiled.beam
file.One way around this is to copy the files to a directory you can write to and compile them there:
You need the
erlang-dev
package installed for that to work.You can run the
ball
example like so:ball
here is the module name, and the Erlang emulator defaults to calling thestart/0
function in that module, which is correct in this case.You don't actually have to compile these examples, however. The Ubuntu
erlang-examples
package ships with them already compiled:After closing the GUI window in each, say
q().
to get out of the emulator. This may seem weird to you until you realize that everything about Erlang is designed with long uptimes in mind. The mere fact that the last process the emulator was running has stopped isn't enough reason for the BEAM emulator to shut itself down. Something else might be started in that same emulator later, after all.