Как исправить ошибку при компиляции bcrypt_elixir или argon_elixir в Windows?

Я пытаюсь создать веб-приложение с аутентификацией в elixir / phoenix. Я столкнулся с ошибками с nmake при попытке скомпилировать argon_elixir или bcrypt_elixir с mix deps.compile или mix phx.server. Как правильно настроить nmake, чтобы иметь возможность компилировать пакеты?

Я установил инструменты сборки Visual Studio и C ++ и установил nmake на свой путь. Затем после выполнения команды mix deps.compile после установки в командной строке соответствующего пути для vcvarsall.bat amd64 я получаю следующую ошибку:

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.


person Kinyugo    schedule 15.05.2019    source источник
comment
Привет @kinyhugo, ошибки, похоже, указывают на то, что заголовки C / C ++ и стандартная библиотека не могут быть найдены. Может быть, вы можете найти эти конкретные ошибки nmake? В качестве альтернативы вы можете использовать pbkdf2_elixir, который не имеет внешних зависимостей.   -  person José Valim    schedule 15.05.2019
comment
@ JoséValim благодарит вас за предложение использовать pbkdf2_elixir, с ним очень легко работать. Также огромное спасибо за потрясающий elixir language.   -  person Kinyugo    schedule 16.05.2019
comment
@ JoséValim для справок в будущем, проще получить все, что построено на Windows, если использовать командную строку разработчика, на которую я ссылался в своем ответе ниже.   -  person Onorio Catenacci    schedule 16.05.2019


Ответы (1)


Попробуйте открыть командную строку разработчика и повторно запустить команду в этой оболочке. Одного наличия nmake в пути недостаточно; компилятор также полагается на некоторые переменные среды (например, LIB), которые необходимо установить. Фактически, сообщение об ошибке, которое вы получаете, говорит мне, что эти переменные среды не установлены.

Командная строка разработчика устанавливает эти переменные среды.

person Onorio Catenacci    schedule 16.05.2019
comment
Привет, @Onorio Catenacci попробовал то, что вы предложили, но все еще не работает. Я попробую переустановить Visual Studio и включить все пакеты для C / C ++, а затем перекомпилировать, но пока я собираюсь работать с pbkdf2_elixir. Спасибо за Ваш ответ. - person Kinyugo; 16.05.2019
comment
Я бы дважды проверил, чтобы убедиться, что переменная среды INCLUDE установлена ​​в командной строке разработчика. Это то, что компилятор использовал бы, чтобы выяснить, где найти файлы .h. - person Onorio Catenacci; 16.05.2019