简体   繁体   中英

How can one fix error compiling bcrypt_elixir or argon_elixir on windows?

I am trying to create a web application with authentication in elixir/phoenix. I have been running into errors with nmake while trying to compile either argon_elixir or bcrypt_elixir with mix deps.compile or mix phx.server.How do I configure nmake correctly to be able to compile the packages?

I have installed visual studio and c++ build tools and set nmake to my path. Then after running the command mix deps.compile after setting the command prompt with the appropriate path for vcvarsall.bat amd64 , I get the following error:

Microsoft (R) Program Maintenance Utility Version 14.20.27508.1
Copyright (C) Microsoft Corporation.  All rights reserved.

        del /Q /F priv
        erl -eval "io:format(\"~s~n\", [lists:concat([\"ERTS_INCLUDE_PATH=\", code:root_dir(), \"/erts-\", erlang:system_info(version), \"/include\"])])" -s init stop -noshell > Makefile.auto.win
        nmake /                   /F Makefile.win priv\argon2_nif.dll

Microsoft (R) Program Maintenance Utility Version 14.20.27508.1
Copyright (C) Microsoft Corporation.  All rights reserved.

        if NOT EXIST "priv" mkdir "priv"
        cl /O2 /EHsc /I"argon2\include" /I"argon2\src" /I"c:/Program Files/erl10.4/erts-10.4/include" /LD /MD /Fepriv\argon2_nif.dll argon2\src\argon2.c argon2\src\core.c argon2\src\blake2\blake2b.c argon2\src\thread.c argon2\src\encoding.c argon2\src\ref.c c_src\argon2_nif.c
Microsoft (R) C/C++ Optimizing Compiler Version 19.20.27508.1 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

argon2.c
argon2\src\argon2.c(18): fatal error C1083: Cannot open include file: 'string.h': No such file or directory
core.c
argon2\src\core.c(20): fatal error C1083: Cannot open include file: 'windows.h': No such file or directory
blake2b.c
argon2\src\blake2\blake2b.c(19): fatal error C1083: Cannot open include file: 'string.h': No such file or directory
thread.c
d:\elixir\codefountain\deps\argon2_elixir\argon2\src\thread.h(34): fatal error C1083: Cannot open include file: 'process.h': No such file or directory
encoding.c
argon2\src\encoding.c(18): fatal error C1083: Cannot open include file: 'stdio.h': No such file or directory
ref.c
argon2\src\ref.c(19): fatal error C1083: Cannot open include file: 'string.h': No such file or directory
argon2_nif.c
c_src\argon2_nif.c(26): fatal error C1083: Cannot open include file: 'stdio.h': No such file or directory
Generating Code...
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.20.27508\bin\HostX64\x64\cl.EXE"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.20.27508\bin\HostX64\x64\nmake.EXE"' : return code '0x2'
Stop.
could not compile dependency :argon2_elixir, "mix compile" failed. You can recompile this dependency with "mix deps.compile argon2_elixir", update it with "mix deps.update argon2_elixir" or clean it with "mix deps.clean argon2_elixir"
==> codefountain
** (Mix) Could not compile with "nmake" (exit status: 2).
One option is to install a recent version of
[Visual C++ Build Tools](http://landinghub.visualstudio.com/visual-cpp-build-tools)
either manually or using [Chocolatey](https://chocolatey.org/) -
`choco install VisualCppBuildTools`.

After installing Visual C++ Build Tools, look in the "Program Files (x86)"
directory and search for "Microsoft Visual Studio". Note down the full path
of the folder with the highest version number. Open the "run" command and
type in the following command (make sure that the path and version number
are correct):

    cmd /K "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64

This should open up a command prompt with the necessary environment variables
set, and from which you will be able to run the "mix compile", "mix deps.compile",
and "mix test" commands.

Try opening up the Developer Command Prompt and re-running the command in that shell. Having nmake in the path is not sufficient all by itself; the compiler also relies on some environment variables (eg LIB) that need to be set. In fact the error message you're getting tells me that those environment variables are not set.

The Developer Command Prompt sets those environment variables.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM