Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't compile on Windows 10, VS2015 #68

Closed
mmischitelli opened this issue Jan 19, 2016 · 21 comments
Closed

Doesn't compile on Windows 10, VS2015 #68

mmischitelli opened this issue Jan 19, 2016 · 21 comments
Assignees

Comments

@mmischitelli
Copy link

Hi
i'm trying to compile on my main dev machine with the following setup:

  • Windows 10
  • VS2015
  • Erlang 18.2.1 (installed in C:\erl7.2.1)
  • Elixir 1.2.0

When I launch mix do deps.get, compile from the VS2015 dev console at the root of my Elixir/Phoenix project I get the following:

== Compilation error on file lib/comeonin/bcrypt.ex ==
** (MatchError) no match of right hand side value: {:error, :on_load_failure}
    (stdlib) erl_eval.erl:669: :erl_eval.do_apply/6

could not compile dependency :comeonin, "mix compile" failed. You can recompile this dependency with "mix deps.compile comeonin", update it with "mix deps.update comeonin" or clean it with "mix deps.clean comeonin"

17:36:11.214 [error] Process #PID<0.239.0> raised an exception
** (MatchError) no match of right hand side value: {:error, {:load_failed, 'Failed to load NIF library d:/test/_build/dev/lib/comeonin/priv/bcrypt_nif: \'Unspecified error\''}}
    lib/comeonin/bcrypt.ex:46: Comeonin.Bcrypt.init/0
    (kernel) code_server.erl:1674: anonymous fn/1 in :code_server.handle_on_load/4

17:36:11.223 [warn]  The on_load function for module Elixir.Comeonin.Bcrypt returned {{:badmatch,
  {:error,
   {:load_failed,
    'Failed to load NIF library d:/test/_build/dev/lib/comeonin/priv/bcrypt_nif: \'Unspecified error\''}}},
 [{Comeonin.Bcrypt, :init, 0, [file: 'lib/comeonin/bcrypt.ex', line: 46]},
  {:code_server, :"-handle_on_load/4-fun-0-", 1,
   [file: 'code_server.erl', line: 1674]}]}

I've found similar error messages in previous, closed issues but I'm still unable to solve my problem with the suggestions given in these threads.

Michele

@riverrun
Copy link
Owner

Try deleting the _build/dev/lib/comeonin directory and then run mix deps.compile and mix compile.
Let me know if that works.

@ronnieoverby
Copy link

Same deal here. I found that the error is Failed to load NIF library at PATH... but when checking path, I see a file there with an added extension, not mentioned in the error: http://i.imgur.com/26KY8N5.png

@ronnieoverby
Copy link

Well, I see other files there, too http://imgur.com/zpXGsyZ

@ronnieoverby
Copy link

Following this bit of advice seemed to fix the issue.

@mmischitelli
Copy link
Author

Hi,
I've already tried deleting the whole _build directory and, as instructions say, run the vcvarsall.bat amd64 but I'm still getting the same problem.

I've even moved the project in a easier directory path, without underscores, blanks et (the current dir is D:\test)

@riverrun
Copy link
Owner

Try editing the deps/comeonin/mix.exs file - change the beginning of the run function from:

def run(_) do
     File.mkdir("priv")

to:

def run(_) do
    File.rm_rf("priv")
    File.mkdir("priv")

and then run mix deps.compile and send me the output if it doesn't work.

@riverrun riverrun self-assigned this Jan 21, 2016
@kotedo
Copy link

kotedo commented Jan 21, 2016

Hi David,

Thank you very much!
I will try that later tonight or early tomorrow morning.

—Kai

On Jan 21, 2016, at 18:17, David Whitlock notifications@github.com wrote:

Try editing the deps/comeonin/mix.exs file - change the beginning of the run function from:
def run(_) do
File.mkdir("priv")

to:
def run(_) do
File.rm_rf("priv")
File.mkdir("priv")

and then run mix deps.compile and send me the output if it doesn't work.


Reply to this email directly or view it on GitHub #68 (comment).

@mmischitelli
Copy link
Author

Hey David that seemed to have solved the problem! Now it's compiling!
Thanks a lot!

Strange thing is that on another computer running Win7 64bit and the same other softwares on mine's (VS, Elixir/Erlang and Phoenix, same versions) didn't show the problem and instead compiled successfully.

Edit: it's still giving the same error when running mix test but otherwise the app is working now

@riverrun
Copy link
Owner

The problem seems to be when updating to a new version of Erlang or Elixir - it's then necessary to recompile the C code.
I think I'll add the rm_rf line to the next minor version.

@riverrun
Copy link
Owner

About the errors with mix test, you will need to run MIX_ENV=test mix deps.compile comeonin and then run mix test. That should fix that issue.

@dylantf
Copy link

dylantf commented Jan 27, 2016

I just went through this same issue, I think it is important to mention that you cannot compile it at all unless you run the vcvarsall.bat amd64 command first, every time you need to do this. Then switch the lines out as directed above and compile. Thanks for the fix!

@davidcotter
Copy link

For 64 bit
cd \Prog...\Visual Studio...\VC
vcvarsall.bat amd64

works thanks @ronnieoverby

@dnarmitage
Copy link

An update to perhaps save others a fair bit of time...

Things seem to have moved on and under Windows 10 I could not find vcvarsall.bat from any way or means of installing visual studio or anything else.

  1. Install the Visual c++ Build Tools ,
  2. open a command window by double clicking "\Program Files (x86)\Microsoft Visual C++ Build Tools\Visual C++ 2015 x64 Native Build Tools Command Prompt" (there are 7 to choose from but that is one worked for me) ,
  3. change to the required projects directory and run your mix deps.compile comeonin or whatever :-) ,

Simples!

@riverrun
Copy link
Owner

Thanks for the update. I'll look into this further and update the docs accordingly.

@dylantf
Copy link

dylantf commented Jan 21, 2017

@dnarmitage if you try to create a c++ project after installing VS it will download the requisite build tools

I do agree it is probably easier to download the build tools directly, since I would guess most developers using Elixir are not using Visual Studio :)

Hopefully once Bash on Windows is sorted out (and Elixir works properly on it) we can avoid this whole step.

@dnarmitage
Copy link

dnarmitage commented Jan 21, 2017 via email

@m2dollars
Copy link

Hi riverrun
image
Could you tell me how to fix this error?

@dylantf
Copy link

dylantf commented Sep 26, 2022

@dementopro You need to follow the instructions that it says in your screenshot to get the make command available in your shell. Install Visual C++ Build Tools and run that cmd /K ... vcvarsall.bat command, then try to install elixir dependencies again.

Alternatively (and probably more preferred these days) is to just use WSL to run elixir.

@m2dollars
Copy link

I've already run this command
cmd /k "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" x64
but still got same error

@aiwaiwa
Copy link

aiwaiwa commented Jan 25, 2023

My steps that lead to a successful build on VS 2022 Community:

  1. Run x64 Native Tools Command Prompt for VS 2022 from the start menu
  2. In the command prompt that appeared:
  • cd to your mix project that has the argon-elixir dependency.
  • (terminate running iex sessions of that folder if any)
  • mix deps.clean --all - optionally to make sure older attempts got wiped out.
  • mix deps.get
  • mix deps.compile
  1. At a regular prompt:
  • Start iex -S mix
  • Try Argon2.hash_pwd_salt("test")

@Birgit-elixir
Copy link

Îch habe, nachdem ich bcrypt_elixir Fehlermeldungen erhalten habe, ebenfalls den obigen Befehl unter VS 2019 ausgeführt und hatte keinen Erfolg. Anders als vor einem halben Jahr, als das Problem schon einmal auftauchte. Ich weiß nicht, wie ich jetzt weiter vorgehen soll. Die Ursprungsfehlermeldung bei mir lautet:
function Bcrypt.Base.checkpass_nif/2 is undefined (module Bcrypt.Base is not available)
fatal error: C1083 und U1077 Die Dateien stdio.h und stdint.h werden nicht gefunden.
Es wäre schön, wenn mir jemand weiterhelfen könnte.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants