small medium large xlarge

28 Jan 2008, 21:51
wasiq hasan (2 posts)

Hi, i am trying to execute chat clietn and geting the folowing error. iam running it on linux.i did not find lib_md5.erl inth ecode i downloaded.

what i ned to make it run? here is te eror

[wasiq@k2 socket_dist]$ make chat_client mkdir -p /home/wasiq/.erlang_config/ cp conf /home/wasiq/.erlang_config/lib_chan.conf make clean - clean up erl -pa ../ -s chat_client test Erlang (BEAM) emulator version 5.6 [source] [smp:2] [async-threads:0] [hipe] [kernel-poll:false]

Eshell V5.6 (abort with ^G) 1> chat_client disconnected unexpected:{‘EXIT’,<0.35.0>,normal}

=ERROR REPORT==== 28-Jan-2008::21:40:05 === Error in process <0.41.0> with exit value: {undef,[{lib_md5,string,[“pzbaplovtpmhazjuvcpdyqishAsDT67aQ”]},{lib_chan,authenticate,4},{lib_chan,connect,5},{chat_client,try_to_connect,4}]}

chat_client disconnected unexpected:{‘EXIT’,<0.41.0>, {undef, [{lib_md5,string, [“pzbaplovtpmhazjuvcpdyqishAsDT67aQ”]}, {lib_chan,authenticate,4}, {lib_chan,connect,5}, {chat_client,try_to_connect,4}]}}

thanks wasiq

01 Feb 2008, 01:56
Alain O'Dea (41 posts)


%% ---
%%  Excerpted from "Programming Erlang"
%%  Copyrights apply to this code. It may not be used to create training material, 
%%  courses, books, articles, and the like. Contact us if you are in doubt.
%%  We make no guarantees that this code is fit for any purpose. 
%%  Visit for more book information.

%% modfied to use BIFs

-export([string/1, file/1, bin/1, binAsBin/1, digest2str/1]).

-define(BLOCKSIZE, 32768).
-define(IN(X,Min,Max), X >= Min, X =< Max).

%% md5:string(string())      -> BinDigest
%% md5:file(FileName)        -> {ok, BinDigest} | {error, E} 
%% md5:digest2str(BinDigest) -> StringDigest

%% md5:file works with chunks so should work correctly with extremely
%% large files

string(Str) -> digest2str(erlang:md5(Str)).

file(File) ->
    case file:open(File, [binary,raw,read]) of
	{ok, P} -> loop(P, erlang:md5_init());
	Error   -> Error

loop(P, C) ->
    case file:read(P, ?BLOCKSIZE) of
	{ok, Bin} ->
	    loop(P, erlang:md5_update(C, Bin));
	eof ->
	    {ok, erlang:md5_final(C)}

digest2str(Digest) -> bin2str(binary_to_list(Digest)).

bin2str([H|T]) ->
    {H1, H2} = byte2hex(H),
bin2str([]) ->

byte2hex(X) -> 
    {nibble2hex(X bsr 4), nibble2hex(X band 15)}.

nibble2hex(X) when ?IN(X, 0, 9)   -> X + $0;
nibble2hex(X) when ?IN(X, 10, 15) -> X - 10 + $a.

%% compute the md5 checksum of a binary
bin(Bin) ->
    C1 = erlang:md5_init(),
    C2 = erlang:md5_update(C1, Bin),
    C3 = erlang:md5_final(C2),

binAsBin(Bin) ->
    C1 = erlang:md5_init(),
    C2 = erlang:md5_update(C1, Bin),
15 Sep 2008, 20:56
Barry Ezell (2 posts)

I experienced this problem too. To solve it, go to the root of the book code and execute “make” from there. If you just “make” the socket_dist directory modules without compiling the root modules, you’ll get this error. That fixed the problem for me.

16 Sep 2008, 23:53
Alain O'Dea (41 posts)

Thank you Barry. Your solution makes more sense. I was unfamiliar with using Make with Erlang when I originally posted. Now I use it all the time :)