riverrun / comeonin

Password hashing specification for the Elixir programming language

Home Page:https://hex.pm/packages/comeonin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Failed to load NIF library on Windows 7 - potential AMD64 vs i386 issue

oboudry opened this issue · comments

Hi,

I'm having the same problem as reported in issue #101

I'm using the x64 version of Erlang OTP 19.3 on a Windows 7 PC. In issue #101 you mentionned that an on_load error is typically related to a build error. As I'm not cross compiling, the only obvious build error I'm thinking of is a x32 build of a DLL and use in x64 erlang.

And I could check that the DLL generated is effectively an i386, and erl.exe an amd64 file.

>perl petype.pl rumbl\deps\comeonin\priv\bcrypt_nif.dll
i386

>perl petype.pl "C:\Program Files\erl8.3\bin\erl.exe"
AMD64

I'm pretty convinced this is the cause, but don't know how to tweak the Makefile.win or change the build so that the x64 dll is built.

Here is the detailed error message I get when loading using the module:

iex(1)> Comeonin.Bcrypt.hashpwsalt("123 super secret")
[warn] The on_load function for module Elixir.Comeonin.Bcrypt returned {:error,
 {:load_failed,
  'Failed to load NIF library c:/Users/obou/Dropbox/Code/Elixir/ProgPhoenix/rumb
l/_build/dev/lib/comeonin/priv/bcrypt_nif: \'Unspecified error\''}}

** (UndefinedFunctionError) function Comeonin.Bcrypt.hashpwsalt/1 is undefined (
module Comeonin.Bcrypt is not available)
    (comeonin) Comeonin.Bcrypt.hashpwsalt("123 super secret")
iex(1)> import Comeonin.Bcrypt
[warn] The on_load function for module Elixir.Comeonin.Bcrypt returned {:error,
 {:load_failed,
  'Failed to load NIF library c:/Users/obou/Dropbox/Code/Elixir/ProgPhoenix/rumb
l/_build/dev/lib/comeonin/priv/bcrypt_nif: \'Unspecified error\''}}

** (CompileError) iex:1: module Comeonin.Bcrypt is not loaded and could not be f
ound

Thanks,

Olivier.

My mistake, I found the solution in #75. The problem is effectively due to compiling a 32bit dll for use with a 64bit erlang.

Solution is to setup the proper environment variables for the environment. This is done like by running vcvarsall.bat with the proper architecture. For a 64bit:

C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC>vcvarsall.bat amd64

A couple lines in the README file might help ease the life of the unfortunate who have to work with Windows. ;-)