Error compiling :bcrypt_elixir and :argon_elixir

I have been running into errors with nmake while trying to compile either argon_elixir or bcrypt_elixir.
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.

Am running on windows 10 and with 2019 visual studio community edition

I assume that this is your answer:

One option is to install a recent version of Visual C++ Build Tools either manually or using Chocolatey - choco install VisualCppBuildTools.

@hauleth thanks for your answer. I have already installed the VisualCppBuildTools and nmake is already available compiling still fails.

I believe what I did last year was

  • install the build tools (using npm install --global windows-build-tools, I believe)
  • run them from powershell
  • mix deps.compile

I didn’t manually set nmake to my path.

1 Like

I hope @AlchemistCamp’s previous suggestion to install windows-build-tools does the trick. In case it doesn’t here’s some checks you can try.

It’s been a while since I’ve fiddled with this stuff in Windows, but IIRC the number in C:\Program Files (x86)\Microsoft Visual Studio 14.0 sometimes changes with Visual Studio version. Does a similar path with a higher number exist on your system? If so and there’s a VC\vcvarsall.bat file in it, try that one instead.

Short of that and the previous suggestion, I’d start searching my system for header files mentioned in errors like this one:

If you need to determine what paths are actually being searched by the compiler, procmon is super useful for that. Good luck.

1 Like

So I tried the npm install, but it didn’t work.

If you’re trying to get something running, I launched my Phoenix application in a docker container, which seemed to do the trick.

VS Code has an extension that allows you to develop inside a docker container:
Developing inside a Container using Visual Studio Code Remote Development

I hope it helps someone out there! Good Luck!