maven-nar / nar-maven-plugin

Native ARchive plugin for Maven
https://maven-nar.github.io/
Apache License 2.0
232 stars 160 forks source link

nar-compile cannot find mt.exe with Visual Studio 2017 #335

Open bribass opened 5 years ago

bribass commented 5 years ago

The attached nar-issue.zip contains a project that builds a JAR and a JNI library. When built on a Windows 10 machine with Visual Studio 2017 (version 15.9.7), nar-compile fails to build the DLL because it cannot find mt.exe.

[INFO] --- nar-maven-plugin:3.6.0:nar-compile (default-nar-compile) @ nar-mt-issue ---
[INFO] Compiling 1 native files
[INFO] 1 total files to be compiled.
[INFO] Found 8 processors available
[INFO] Limited used processors to 1
[INFO]
Starting Core 0 with 1 source files...
[INFO] native.c
[INFO] Linking...
[INFO] Starting link {link /MANIFEST /MANIFESTFILE:C:\src\terrsrv\pythonsrv\src\nar-issue\target\nar\nar-mt-issue-0.1-SNAPSHOT-amd64-Windows-msvc-jni\lib\amd64-Windows-msvc\jni\native.manifest /MACHINE:X64 /LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\lib\x64 /LIBPATH:C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17763.0\ucrt\x64 /LIBPATH:C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17763.0\um\x64 /NOLOGO /DLL /SUBSYSTEM:CONSOLE /INCREMENTAL:NO}
[INFO]    Creating library native.lib and object native.exp
[INFO] + mt.exe /manifest C:\src\terrsrv\pythonsrv\src\nar-issue\target\nar\nar-mt-issue-0.1-SNAPSHOT-amd64-Windows-msvc-jni\lib\amd64-Windows-msvc\jni\native.manifest /outputresource:C:\src\terrsrv\pythonsrv\src\nar-issue\target\nar\nar-mt-issue-0.1-SNAPSHOT-amd64-Windows-msvc-jni\lib\amd64-Windows-msvc\jni\native.dll;#2
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 16.039 s
[INFO] Finished at: 2019-03-01T14:32:01-08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.maven-nar:nar-maven-plugin:3.6.0:nar-compile (default-nar-compile) on project nar-mt-issue: Could not launch cmd.exe /X /C "mt.exe /manifest C:\src\terrsrv\pythonsrv\src\nar-issue\target\nar\nar-mt-issue-0.1-SNAPSHOT-amd64-Windows-msvc-jni\lib\amd64-Windows-msvc\jni\native.manifest /outputresource:C:\src\terrsrv\pythonsrv\src\nar-issue\target\nar\nar-mt-issue-0.1-SNAPSHOT-amd64-Windows-msvc-jni\lib\amd64-Windows-msvc\jni\native.dll;#2": Error while executing process. Cannot run program "mt.exe": CreateProcess error=2, The system cannot find the file specified -> [Help 1]

If I add the directory C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x64 (the directory in which mt.exe resides) to the PATH, nar-compile succeeds. However, since nar-maven-plugin automatically determines paths for other parts of nar-compile (i.e., the compiler and the linker), this is not expected (or desired) behavior.

bribass commented 5 years ago

Attached are the following files:

bribass commented 5 years ago

OK, now I feel stupid. This failure is with version 3.6.0 (the latest available version on Maven Central). I tried again with the current master, and everything is working as expected. Is there any estimation on when a new version (either the 3.7.0 release that is implied by the presence of a tag in the repository, or a 3.7.1 containing the current master) will be available?