Windows原生安装argon2_elixir遇编译错误求解决方案
嘿,我之前在Windows上折腾argon2_elixir编译的时候也碰到过几乎一样的问题,给你分享下我踩坑后总结的解决办法:
先把你遇到的错误情况理清楚:
第一个错误场景
运行编译命令时直接报错找不到nmake:
could not compile dependency :argon2_elixir, "mix compile" failed. Errors may have been logged above. You can recompile this dependency with "mix deps.compile argon2_elixir --force", update it with "mix deps.update argon2_elixir" or clean it with "mix deps.clean argon2_elixir" ** (Mix) "nmake" not found in the path. If you have set the MAKE environment variable, please make sure it is correct.
手动设置MAKE环境变量后依然报错
设置后运行mix deps.compile argon2_elixir --force还是失败,路径显示被截断:
==> argon2_elixir could not compile dependency :argon2_elixir, "mix compile" failed. Errors may have been logged above. You can recompile this dependency with "mix deps.compile argon2_elixir --force", update it with "mix deps.update argon2_elixir" or clean it with "mix deps.clean argon2_elixir" ** (Mix) "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34...
具体解决步骤
先确认Visual Studio的环境装对了
你已经装了VS2022 Community,但一定要检查是否勾选了「桌面开发使用C++」这个工作负载——很多人会漏装这个,导致没有nmake和C编译环境。如果没装的话,打开VS Installer补装这个组件就行。别手动设置MAKE环境变量!用VS自带的命令行工具
手动设MAKE很容易因为路径不完整、版本不匹配出问题。正确的做法是:
找到开始菜单里的「适用于VS 2022的x64本机工具命令提示符」(如果是32位系统就找x86版本),打开这个命令行窗口,然后切换到你的Elixir项目目录,依次运行:mix deps.clean argon2_elixir mix deps.get mix deps.compile argon2_elixir --force这个命令行窗口会自动帮你配置好所有VS的编译环境变量,包括nmake的正确路径、编译器路径,完全不用手动折腾。
额外排查点
检查你的Erlang/OTP和Elixir版本是否和当前argon2_elixir兼容:比如argon2_elixir v4.x+需要Erlang/OTP 24及以上版本,如果版本不匹配也会编译失败;要是用的是较旧的argon2_elixir版本,也可以试试更新到最新兼容版,运行mix deps.update argon2_elixir就行。
备注:内容来源于stack exchange,提问作者whizboy

