you're reading...
Chicagoboss, Erlang, SmartOS

Installing Bcrypt for Chicago Boss Projects

I started using Chicago Boss as a Erlang based MVC framework.

So far I dig it, trying to get my head around Erlang code still.

One of the example projects interested me that uses PostgreSQL and login with Bcrypted password.

I got an error installing bcrypt as a dependency of my project using rebar and took a big of googling around to finally get a fix.

I added this as my rebar.config dependency:

{bcrypt, "0.5.0", {git, "git://github.com/spawngrid/erlang-bcrypt.git", {branch, "rebar-update"}}}

ran rebar get-deps and compile but got this error:

==> bcrypt (compile)
Compiled src/bcrypt_app.erl
Compiled src/bcrypt_sup.erl
Compiled src/bcrypt_nif_worker.erl
Compiled src/bcrypt_nif.erl
Compiled src/bcrypt_port.erl
Compiled src/bcrypt.erl
Compiled src/bcrypt_pool.erl
Compiled src/bcrypt_port_sup.erl
Compiling c_src/blowfish.c
Compiling c_src/bcrypt.c
Compiling c_src/bcrypt_nif.c
Compiling c_src/async_queue.c
Undefined first referenced
symbol in file
gethostbyname_r /usr/local/lib/erlang/lib/erl_interface-3.7.14/lib/libei.a(ei_resolve.o)
gethostbyaddr /usr/local/lib/erlang/lib/erl_interface-3.7.14/lib/libei.a(ei_resolve.o)
gethostbyname /usr/local/lib/erlang/lib/erl_interface-3.7.14/lib/libei.a(ei_resolve.o)
ld: fatal: symbol referencing errors. No output written to priv/bcrypt
collect2: error: ld returned 1 exit status
ERROR: Command [compile] failed!

Looks like ld can’t find libnsl, I added -lnsl and to the rebar.config and that fixed it.

vi deps/bcrypt/rebar.config

[{clean, "rm -f priv/bcrypt"},
"c_src/bcrypt_port.c c_src/bcrypt.o c_src/blowfish.o "
"$LDFLAGS $ERL_LDFLAGS -lpthread -lnsl "
"-o priv/bcrypt"}]}.

Make sure you leave a space at the end, or you will get errors about not being able to find priv/bcrypt.

Now bcrypt compiled ok for me.




  1. Pingback: Chicago Boss, PostgreSQL, SmartOS fun… | Nullworks - October 29, 2013

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s