views:

1404

answers:

3

I have tried installing Erlang 13B through to 12B to follow the tutorials.

Everytime I get to c(tut), I get an error instead of (ok, tut), so it seems like there are no modules installed, can anyone point me in the right direction?

I've tried e-macs but I don't really know how to use it and haven't even got close to getting the erlang mode working, for instance where do I type:

(setq load-path (cons "C:/Program Files/erl5.6.2/lib/tools-/emacs" load-path)) (setq erlang-root-dir "C:/Program Files/erl5.6.2") (setq exec-path (cons "C:/Program Files/erl5.6.2/bin" exec-path)) (require 'erlang-start)

and what commands do I type in to get this working?

can anyone help? I'm going mental.

+2  A: 

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 run it 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.

So, you have to change your working directory after starting the Erlang shell before trying to compile your code. If it's on the Desktop, the command will be 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 go command line on it on such systems. The Cygwin bash shell will give you a more Linux or OS X like environment for doing something like that, which will help you work with other tutorials that are structured for those OSes.

Warren Young
By the way, once you have a *.beam file in the directory with other Erlang code, you can set up a Windows file association between *.beam files and werl.exe, so that when you double-click them, Erlang loads them up and implicitly ends up setting its working directory to the location of the file.
Warren Young
+3  A: 

After you install Erlang open the shell and do:

1> pwd().
C:/Program Files/erl5.7.1/usr
ok
2>

Assume you have a file; "tut.erl" on your desktop. Content might look like this:

-module(tut).
-compile(export_all).

hello_world() ->
  hello.

You must change the path of the current working directory to the desktop first (or where ever you want to do the compile). Like this perhaps:

2> cd("F:/Desktop").
F:/Desktop
ok
3>

Then you can perform the compile.

3> c(tut).
{ok,tut}
4>

Then test the module

4> tut:hello_world().
hello
5>

More info refer to the documentation here: Erlang official documentation More info on the shell, look here: Shell module

Hope this gets your started.

Mazen Harake
Oh and by the way, in windows the absolutely best tip I have is to create a windows shortcut to werl.exe for each project you have and then change the "Run in" property to the current working directory. Another tip is to add flags in the "Target" property such as -sname, -setcookie (useful in distributed environments) and perhaps -pa to add additional paths to your code search paths. more info about those here: http://erlang.org/doc/man/erl.html
Mazen Harake
Thanks for taking time out to answer my question but I can't get the c(tut) to work, I still get this:Erlang (BEAM) emulator version 5.6.2 [smp:2] [async-threads:0]Eshell V5.6.2 (abort with ^G)1> cd("F:/Desktop").C:/Program Files/erl5.6.2/usrok2> c(tut)../tut.erl:none: no such file or directoryerror3> Since all the tutorials seem to assume that these modules are already installed I thought they came as standard; I can't seem to track own any modules, which is a bit of a downer.
Niall
Your command cd("F:/Desktop"). is hitting the windows command line problem that cd cannot change directories across drive letters. Modify your erlang shortcut to set working directory to F:btw help(). shows shell commands.
danio
+1  A: 

You can also create an initialization file named .erlang under YourErlangInstallationPath\usr\

the content of the file should look something like this;

io:format("consulting .erlang in ~p~n" ,
[element(2,file:get_cwd())]).
%% Edit to the directory where you store your code
c:cd("O:/Erlang.Umut").
io:format("Now in:~p~n" , [element(2,file:get_cwd())]).

it will automatically change the path to your working folder. (Obviously, my path is O:/Erlang.Umut, you need to replace it with yours.)

No need to change folders every time you launch console. Console will be able to reach your erl files directly.

detay