Compiling Erlang code on Windows

前端 未结 6 834
夕颜
夕颜 2021-02-08 03:48

I installed Erlang 13B and tried to follow the tutorials.

Every time I get to c(tut), I get an error instead of (ok, tut), so it seems like the

6条回答
  •  日久生厌
    2021-02-08 04:23

    For c(tut) to work, there has to be a tut.erl file in the current directory.

    This is easy to accomplish if you start the Erlang interpreter from the command line, as is common on systems like Linux and OS X, but this isn't the usual pattern on Windows. When you start Erlang on Windows from the icon in the Start menu, the current working directory defaults to the location of werl.exe, which isn't where your tut.erl file is.

    To make your command work as expected, you have to change your working directory to be the location of tut.erl after starting the Erlang shell. If tut.erl is on the Desktop, the command will be something like this on Vista or Windows 7:

    cd("c:/Users/myname/Desktop").
    

    (Yes, you have to use forward slashes. Backslashes are special in Erlang strings.)

    On Windows XP and older, your Desktop folder is buried much deeper. It might be simpler to put werl.exe in the system PATH and use the command line on such systems.

    It isn't necessary, but you might want to consider installing Cygwin. Its Bash shell will give you a more Linux or OS X like environment, which will help you work with other tutorials that are structured for those OSes.

提交回复
热议问题