gluonhq / gluonfx-maven-plugin

Plugin that simplifies creating native images for Java/JavaFX maven projects
BSD 3-Clause "New" or "Revised" License
194 stars 39 forks source link

(Windows) Error: Cannot run program "cl" #195

Closed matintokyo closed 4 years ago

matintokyo commented 4 years ago

Hi! I tried this maven plugin on Windows 10 after having followed the instructions.

It seems the build tools cannot be found though, as the client:build goal fails with the following error:

[ERROR] Failed to execute goal com.gluonhq:client-maven-plugin:0.1.27:compile (default-cli) on project abcde: Error: Cannot run program "cl"

In the x64 Native Tools Command Prompt for VS 2019, typing "cl" yields the following: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community>cl Microsoft (R) C/C++ Optimizing Compiler Version 19.26.28806 for x64 Copyright (C) Microsoft Corporation. All rights reserved.

so it seems that CL is installed correctly.

(I also manually tried to add cl to my system "PATH" environment, but the build still fails as it cannot find the required libraries such as stdio.h).

One thing that jumps to mind is that I had VS Code 2019 installed with Japanese Language Pack in the past. I however uninstalled everything and reinstalled with English Language Pack only. Could it be that something remained that is causing issues?

Thank you for any tip to get me going!

xerz-one commented 4 years ago

I get a similar error in Debian Sid, using the latest GraalVM and Maven plugins:

[Wed Jun 17 22:02:08 CEST 2020][INFO] We will now compile your code for x86_64-linux-linux. This may take some time.
java.io.IOException: Cannot run program "jar": error=2, No such file or directory
    at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1128)
    at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1071)
    at com.gluonhq.substrate.util.ProcessRunner.setupProcess(ProcessRunner.java:336)
    at com.gluonhq.substrate.util.ProcessRunner.runProcess(ProcessRunner.java:194)
    at com.gluonhq.substrate.util.ProcessRunner.runProcess(ProcessRunner.java:180)
    at com.gluonhq.substrate.model.ClassPath.getJars(ClassPath.java:125)
    at com.gluonhq.substrate.config.ConfigResolver.<init>(ConfigResolver.java:77)
    at com.gluonhq.substrate.target.AbstractTargetConfiguration.getConfigurationFileArgs(AbstractTargetConfiguration.java:476)
    at com.gluonhq.substrate.target.AbstractTargetConfiguration.compile(AbstractTargetConfiguration.java:150)
    at com.gluonhq.substrate.target.LinuxTargetConfiguration.compile(LinuxTargetConfiguration.java:90)
    at com.gluonhq.substrate.SubstrateDispatcher.nativeCompile(SubstrateDispatcher.java:414)
    at com.gluonhq.NativeCompileMojo.execute(NativeCompileMojo.java:54)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 2.774 s
Finished at: 2020-06-17T22:02:08+02:00
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: java.io.IOException: error=2, No such file or directory
    at java.base/java.lang.ProcessImpl.forkAndExec(Native Method)
    at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:340)
    at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:271)
    at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1107)
    ... 33 more
Final Memory: 16M/64M
------------------------------------------------------------------------
Failed to execute goal com.gluonhq:client-maven-plugin:0.1.27:compile (default-cli) on project ajedrez: Error: Cannot run program "jar": error=2, No such file or directory -> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.

For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 12.295 s
Finished at: 2020-06-17T22:02:08+02:00
Final Memory: 22M/84M
------------------------------------------------------------------------
Failed to execute goal com.gluonhq:client-maven-plugin:0.1.27:build (default-cli) on project ajedrez: Error, client:build failed -> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.

For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
jperedadnr commented 4 years ago

@xerz-one This issue is about cl which is used only on Windows. Probably best if you file a new issue.

jperedadnr commented 4 years ago

@matintokyo Can you run cl -v and post the result?

matintokyo commented 4 years ago

@jperedadnr Thank you for your kind reply. Here is the output of cl -v

Microsoft (R) C/C++ Optimizing Compiler Version 19.26.28806 for x64 Copyright (C) Microsoft Corporation. All rights reserved. cl : Command line warning D9002 : ignoring unknown option '-v' cl : Command line error D8003 : missing source filename

cl /v did not work either. I tried to get a list of known options with cl /help but did not find anything like -v. Here is cl /help output just in case.

`Microsoft (R) C/C++ Optimizing Compiler Version 19.26.28806 for x64 Copyright (C) Microsoft Corporation. All rights reserved.

                     C/C++ COMPILER OPTIONS

                          -OPTIMIZATION-

/O1 maximum optimizations (favor space) /O2 maximum optimizations (favor speed) /Ob inline expansion (default n=0) /Od disable optimizations (default) /Og enable global optimization /Oi[-] enable intrinsic functions /Os favor code space /Ot favor code speed /Ox optimizations (favor speed) /favor:<blend|AMD64|INTEL64|ATOM> select processor to optimize for, one of: blend - a combination of optimizations for several different x64 processors AMD64 - 64-bit AMD processors INTEL64 - Intel(R)64 architecture processors ATOM - Intel(R) Atom(TM) processors

                         -CODE GENERATION-

/Gu[-] ensure distinct functions have distinct addresses /Gw[-] separate global variables for linker /GF enable read-only string pooling /Gm[-] enable minimal rebuild /Gy[-] separate functions for linker /GS[-] enable security checks /GR[-] enable C++ RTTI /GX[-] enable C++ EH (same as /EHsc) /guard:cf[-] enable CFG (control flow guard) /EHs enable C++ EH (no SEH exceptions) /EHa enable C++ EH (w/ SEH exceptions) /EHc extern "C" defaults to nothrow (press to continue) /EHr always generate noexcept runtime termination checks /fp:<except[-]|fast|precise|strict> choose floating-point model: except[-] - consider floating-point exceptions when generating code fast - "fast" floating-point model; results are less predictable precise - "precise" floating-point model; results are predictable strict - "strict" floating-point model (implies /fp:except) /Qfast_transcendentals generate inline FP intrinsics even with /fp:except /Qspectre[-] enable mitigations for CVE 2017-5753 /Qpar[-] enable parallel code generation /Qpar-report:1 auto-parallelizer diagnostic; indicate parallelized loops /Qpar-report:2 auto-parallelizer diagnostic; indicate loops not parallelized /Qvec-report:1 auto-vectorizer diagnostic; indicate vectorized loops /Qvec-report:2 auto-vectorizer diagnostic; indicate loops not vectorized /GL[-] enable link-time code generation /volatile:<iso|ms> choose volatile model: iso - Acquire/release semantics not guaranteed on volatile accesses ms - Acquire/release semantics guaranteed on volatile accesses /GA optimize for Windows Application /Ge force stack checking for all funcs /Gs[num] control stack checking calls /Gh enable _penter function call /GH enable _pexit function call /GT generate fiber-safe TLS accesses /RTC1 Enable fast checks (/RTCsu) /RTCc Convert to smaller type checks /RTCs Stack Frame runtime checking /RTCu Uninitialized local usage checks /clr[:option] compile for common language runtime, where option is: pure - produce IL-only output file (no native executable code) safe - produce IL-only verifiable output file netcore - produce assemblies targeting .NET Core runtime noAssembly - do not produce an assembly nostdlib - ignore the system .NET framework directory when searching for assemblies nostdimport - do not import any required assemblies implicitly (press to continue) initialAppDomain - enable initial AppDomain behavior of Visual C++ 2002 /homeparams Force parameters passed in registers to be written to the stack /GZ Enable stack checks (/RTCs) /Gv __vectorcall calling convention /arch:<AVX|AVX2|AVX512> minimum CPU architecture requirements, one of: AVX - enable use of instructions available with AVX-enabled CPUs AVX2 - enable use of instructions available with AVX2-enabled CPUs AVX512 - enable use of instructions available with AVX-512-enabled CPUs /QIntel-jcc-erratum enable mitigations for Intel JCC erratum /Qspectre-load Enable spectre mitigations for all instructions which load memory /Qspectre-load-cf Enable spectre mitigations for all control-flow instructions which load memory

                          -OUTPUT FILES-

/Fa[file] name assembly listing file /FA[scu] configure assembly listing /Fd[file] name .PDB file /Fe name executable file /Fm[file] name map file /Fo name object file /Fp name precompiled header file /Fr[file] name source browser file /FR[file] name extended .SBR file /Fi[file] name preprocessed file /Fd: name .PDB file /Fe: name executable file /Fm: name map file /Fo: name object file /Fp: name .PCH file /FR: name extended .SBR file /Fi: name preprocessed file /doc[file] process XML documentation comments and optionally name the .xdc file

                          -PREPROCESSOR-

/AI

add to assembly search path /FU forced using assembly/module /C don't strip comments /D{=|#} define macro /E preprocess to stdout /EP preprocess to stdout, no #line (press to continue) /P preprocess to file /Fx merge injected code to file /FI name forced include file /U remove predefined macro /u remove all predefined macros /I add to include search path /X ignore "standard places" /PH generate #pragma file_hash when preprocessing

                            -LANGUAGE-

/std:<c++14|c++17|c++latest> C++ standard version c++14 - ISO/IEC 14882:2014 (default) c++17 - ISO/IEC 14882:2017 c++latest - latest draft standard (feature set subject to change) /permissive[-] enable some nonconforming code to compile (feature set subject to change) (on by default) /Ze enable extensions (default) /Za disable extensions /ZW enable WinRT language extensions /Zs syntax check only /Zc:arg1[,arg2] C++ language conformance, where arguments can be: forScope[-] enforce Standard C++ for scoping rules wchar_t[-] wchar_t is the native type, not a typedef auto[-] enforce the new Standard C++ meaning for auto trigraphs[-] enable trigraphs (off by default) rvalueCast[-] enforce Standard C++ explicit type conversion rules strictStrings[-] disable string-literal to [char|wchar_t]* conversion (off by default) implicitNoexcept[-] enable implicit noexcept on required functions threadSafeInit[-] enable thread-safe local static initialization inline[-] remove unreferenced function or data if it is COMDAT or has internal linkage only (off by default) sizedDealloc[-] enable C++14 global sized deallocation functions (on by default) throwingNew[-] assume operator new throws on failure (off by default) referenceBinding[-] a temporary will not bind to an non-const lvalue reference (off by default) twoPhase- disable two-phase name lookup ternary[-] enforce C++11 rules for conditional operator (off by default) noexceptTypes[-] enforce C++17 noexcept rules (on by default in C++17 or later) alignedNew[-] enable C++17 alignment of dynamically allocated objects (on by default) (press to continue) hiddenFriend[-] enforce Standard C++ hidden friend rules (implied by /permissive-) externC[-] enforce Standard C++ rules for 'extern "C"' functions (implied by /permissive-) lambda[-] better lambda support by using the newer lambda processor (off by default) tlsGuards[-] generate runtime checks for TLS variable initialization (on by default) /await enable resumable functions extension /constexpr:depth recursion depth limit for constexpr evaluation (default: 512) /constexpr:backtrace show N constexpr evaluations in diagnostics (default: 10) /constexpr:steps terminate constexpr evaluation after N steps (default: 100000) /Zi enable debugging information /Z7 enable old-style debug info /Zo[-] generate richer debugging information for optimized code (on by default) /ZH:[MD5|SHA1|SHA_256] hash algorithm for calculation of file checksum in debug info (default: MD5) /Zp[n] pack structs on n-byte boundary /Zl omit default library name in .OBJ /vd{0|1|2} disable/enable vtordisp /vm type of pointers to members /ZI enable Edit and Continue debug info /openmp enable OpenMP 2.0 language extensions /openmp:experimental enable OpenMP 2.0 language extensions plus select OpenMP 3.0+ language extensions

                          -MISCELLANEOUS-

@ options response file /?, /help print this help message /bigobj generate extended object format /c compile only, no link /errorReport:option deprecated. Report internal compiler errors to Microsoft none - do not send report prompt - prompt to immediately send report queue - at next admin logon, prompt to send report (default) send - send report automatically /FC use full pathnames in diagnostics /H max external name length /J default char type is unsigned /MP[n] use up to 'n' processes for compilation (press to continue) /nologo suppress copyright message /showIncludes show include file names /Tc compile file as .c /Tp compile file as .cpp /TC compile all files as .c /TP compile all files as .cpp /V set version string /Yc[file] create .PCH file /Yd put debug info in every .OBJ /Yl[sym] inject .PCH ref for debug lib /Yu[file] use .PCH file /Y- disable all PCH options /Zm max memory alloc (% of default) /FS force to use MSPDBSRV.EXE /source-charset:|.nnnn set source character set /execution-charset:|.nnnn set execution character set /utf-8 set source and execution character set to UTF-8 /validate-charset[-] validate UTF-8 files for only legal characters /fastfail[-] enable fast-fail mode /JMC[-] enable native just my code

                            -LINKING-

/LD Create .DLL /LDd Create .DLL debug library /LN Create a .netmodule /F set stack size /link [linker options and libraries] /MD link with MSVCRT.LIB /MT link with LIBCMT.LIB /MDd link with MSVCRTD.LIB debug lib /MTd link with LIBCMTD.LIB debug lib

                          -CODE ANALYSIS-

/analyze[-] Enable native analysis /analyze:quiet[-] No warning to console /analyze:log Warnings to file /analyze:autolog Log to .pftlog /analyze:autolog:ext Log to ./analyze:autolog- No log file /analyze:WX- Warnings not fatal /analyze:stacksize Max stack frame /analyze:max_paths Max paths /analyze:only Analyze, no code gen

                          -DIAGNOSTICS-

(press to continue) /diagnostics:<args,...> controls the format of diagnostic messages: classic - retains prior format column[-] - prints column information caret[-] - prints column and the indicated line of source /Wall enable all warnings /w disable all warnings /W set warning level (default n=1) /Wv:xx[.yy[.zzzzz]] disable warnings introduced after version xx.yy.zzzzz /WX treat warnings as errors /WL enable one line diagnostics /wd disable warning n /we treat warning n as an error /wo issue warning n once /w set warning level 1-4 for n /external:I - location of external headers /external:env: - environment variable with locations of external headers /external:anglebrackets - treat all headers included via <> as external /external:W - warning level for external headers /external:templates[-] - evaluate warning level across template instantiation chain /sdl enable additional security features and warnings`

xerz-one commented 4 years ago

@jperedadnr Don't worry, found my specific issue is related to Flatpak filesystem isolation/permissions, as I was calling Maven from Flatpak versions of IntelliJ IDEA and Netbeans.

matintokyo commented 4 years ago

@jperedadnr The version of CL installed via Visual Studio Installer was C++/CLI support for v142 build tools (14.26) For other components I consistently selected 14.26 version.

matintokyo commented 4 years ago

Hi. I wanted to report the issue was caused by running the maven client:build task from within IntelliJ. Re-reading the docs and understanding better now I realized I had to run the maven command from the x64 Native Tools Command Prompt for VS 2019.

The error is now gone, this issue can be closed!