5.编译并运行erlang程序

1.停止erlang系统方法:
   ctrl+C(Windows下 ctrl+Break).
   不可控关闭BIF函数: erlang:halt() 强制停止系统(小瑕疵:对于大型的数据库操作程序,可能在下次需要进行一些回复操作)
   可控关闭:q().该函数是init:stop()在shell中的简写,该操作会做一些清除和关闭操作,保证系统正确关闭
2.为文件加载器设定加载路径
   code:get_path(). 获得当前设定的文件加载路径列表
   @spec code:add_patha(Dir) 增加新目录到当前加载路径列表的开头
   @spec code:add_patha(Dir) 增加新目录到当前加载路径列表的末尾
   @spec code:all_loaded()   返回所有加载的模块,有利于确定那些模块加载出错
   @spec code:clash() 分析加载目录是否有重复模块
   注:code模块有些函数可以用来分析加载路径
   init:get_argument(home) 获得erlang系统所需的home目录
3. erlang程序运行方式
   erlang代码如下
   -module(hello).
   -export([start/0]).

   start() ->
    io:format("Hello world~n").
   (1). shell中编译运行:
       c(hello).
       hello:start().
   (2). 命令行中编译运行:
       F:\programming\Erlang\erlang程序设计中文版\code>erlc hello.erl
       F:\programming\Erlang\erlang程序设计中文版\code>erl -noshell -s hello start -s init stop
   (3). window下bat批处理文件中运行
       "D:\erlang5\bin\erl.exe" -noshell -s hello start -s init stop
   (4). 快速脚本
        erl -eval 'io:format("Memory:~p~n",[erlang:memory(total)])' -noshell -s init stop (windows下无输出)
   (5). escript脚本运行,代码不会编译为beam字节码(在window下是否运行,待研究)
        脚本文件名:hello
        #!/usr/bin/env escript
        main(_) ->
            io:format("Hello world\n").
        在unix下运行: chmod u+x hello
                       ./hello
        在window下运行:escript hello
4.使用makefile进行自动编译
5.解决系统死锁问题
6.shell无响应  shell JCL(shell job control languge) 在Eshell V5.6.2中不起作用或着这仅仅是在window下的问题,linux待验证(待解决)
7.获得erlang帮助  112页
8.erlang崩溃转储文件分析 webtool:start().

你可能感兴趣的:(5.编译并运行erlang程序)