6

I've been experimenting with Gluon's client maven plugin on a Windows machine for a project of mine. I decided to try out one of their "hello world" examples, here. I followed all of the steps on how to configure the machine.

However, I've encountered some errors. For some reason, the compiling always fails and gives me an error "Cannot run program "cl"". Does anyone have any clue on how to fix this?

I am running the client:build command in a "x64 Native Tools Command Prompt for VS 2019" window.

The logs are below:

java.io.IOException: Cannot run program "cl" (in directory "C:\Users\Evan\Documents\client-samples\Maven\HelloFXML\target\client\x86_64-windows\gvm\hellofxml"): CreateProcess error=2, The system cannot find the file specified
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1128)
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1071)
[INFO] ------------------------------------------------------------------------
        at com.gluonhq.substrate.util.ProcessRunner.setupProcess(ProcessRunner.java:336)
[INFO] BUILD FAILURE
        at com.gluonhq.substrate.util.ProcessRunner.runProcess(ProcessRunner.java:194)
[INFO] ------------------------------------------------------------------------
        at com.gluonhq.substrate.target.AbstractTargetConfiguration.compileAdditionalSources(AbstractTargetConfiguration.java:330)
[INFO] Total time:  2.860 s
        at com.gluonhq.substrate.target.AbstractTargetConfiguration.compile(AbstractTargetConfiguration.java:130)
[INFO] Finished at: 2020-06-02T17:37:39-04:00
        at com.gluonhq.substrate.SubstrateDispatcher.nativeCompile(SubstrateDispatcher.java:414)
[INFO] ------------------------------------------------------------------------
        at com.gluonhq.NativeCompileMojo.execute(NativeCompileMojo.java:54)
[ERROR] Failed to execute goal com.gluonhq:client-maven-plugin:0.1.26:compile (default-cli) on project hellofxml: Error: Cannot run program "cl" (in directory "C:\Users\Evan\Documents\client-samples\Maven\HelloFXML\target\client\x86_64-windows\gvm\hellofxml"): CreateProcess error=2, The system cannot find the file specified -> [Help 1]
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
[ERROR]
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
[ERROR]
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
[ERROR] For more information about the errors and possible solutions, please read the following articles:
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:957)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:289)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:193)
        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:567)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
        at java.base/java.lang.ProcessImpl.create(Native Method)
        at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:420)
        at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:151)
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1107)
        ... 29 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  5.141 s
[INFO] Finished at: 2020-06-02T17:37:39-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.gluonhq:client-maven-plugin:0.1.26:build (default-cli) on project hellofxml: Error, client:build failed -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

When I add C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\bin\HostX64\x64 to my system path, the plugin gives the following error in the logs. (I ran this command in admin mode)

[Tue Jun 02 18:28:07 EDT 2020][INFO] ==================== COMPILE TASK ====================
[Tue Jun 02 18:28:08 EDT 2020][FINE] PB Command for check version: D:\graalvm-ce-java11-20.2.0-dev\bin\java -version
[Tue Jun 02 18:28:08 EDT 2020][FINE] Start process check version...
[Tue Jun 02 18:28:09 EDT 2020][FINE] [SUB] openjdk version "11.0.7" 2020-04-14
[Tue Jun 02 18:28:09 EDT 2020][FINE] [SUB] OpenJDK Runtime Environment GraalVM CE 20.2.0-dev (build 11.0.7+10-jvmci-20.1-b02)
[Tue Jun 02 18:28:09 EDT 2020][FINE] [SUB] OpenJDK 64-Bit Server VM GraalVM CE 20.2.0-dev (build 11.0.7+10-jvmci-20.1-b02, mixed mode, sharing)
[Tue Jun 02 18:28:09 EDT 2020][FINE] Result for check version: 0
[Tue Jun 02 18:28:09 EDT 2020][INFO] We will now compile your code for x86_64-microsoft-windows. This may take some time.
[Tue Jun 02 18:28:09 EDT 2020][FINE] Extracting native libs to: C:\Users\Evan\Documents\client-samples\Maven\HelloFXML\target\client\x86_64-windows\gvm\lib
[Tue Jun 02 18:28:09 EDT 2020][FINE] Looking for resource: /native/windows/launcher.c
[Tue Jun 02 18:28:09 EDT 2020][FINE] PB Command for compile-additional-sources: cl -c -DSUBSTRATE /MD /D_UNICODE /DUNICODE /DWIN32 /D_WINDOWS -IC:\Users\Evan\Documents\client-samples\Maven\HelloFXML\target\client\x86_64-windows\gvm\hellofxml launcher.c
[Tue Jun 02 18:28:09 EDT 2020][FINE] Start process compile-additional-sources...
[Tue Jun 02 18:28:09 EDT 2020][FINE] [SUB] Microsoft (R) C/C++ Optimizing Compiler Version 19.25.28610.4 for x64
[Tue Jun 02 18:28:09 EDT 2020][FINE] [SUB] Copyright (C) Microsoft Corporation.  All rights reserved.
[Tue Jun 02 18:28:09 EDT 2020][FINE] [SUB] 
[Tue Jun 02 18:28:09 EDT 2020][FINE] [SUB] launcher.c
[Tue Jun 02 18:28:09 EDT 2020][FINE] [SUB] launcher.c(28): fatal error C1083: Cannot open include file: 'stdio.h': No such file or directory
[Tue Jun 02 18:28:09 EDT 2020][FINE] Result for compile-additional-sources: 2
[Tue Jun 02 18:28:09 EDT 2020][SEVERE] Process compile-additional-sources failed with result: 2
Check the log files under C:\Users\Evan\Documents\client-samples\Maven\HelloFXML\target\client\x86_64-windows\gvm\log
And please check https://docs.gluonhq.com/client/ for more information.
[Tue Jun 02 18:28:09 EDT 2020][INFO] Logging process [compile-additional-sources] to file: C:\Users\Evan\Documents\client-samples\Maven\HelloFXML\target\client\log\process-compile-additional-sources-1591136889122.log
[Tue Jun 02 18:28:09 EDT 2020][SEVERE] Compiling failed.
Check the log files under C:\Users\Evan\Documents\client-samples\Maven\HelloFXML\target\client\x86_64-windows\gvm\log
And please check https://docs.gluonhq.com/client/ for more information.

These are the VS 2019 components I have installed.

Evan Zheng
  • 135
  • 8
  • Did you follow instructions at https://github.com/gluonhq/client-samples#windows? Make sure you install all listed components. `cl` is the Windows compiler, You should be able to run from the x64 command line something like `cl -v`. – José Pereda Jun 02 '20 at 21:56
  • @JoséPereda Yep, I did. It says that 'cl' is not recognized as an internal or external command. I tried adding the following directory to my system path environment variable: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\bin\HostX64\x64. After that, I could call cl from the visual studio command line but I still couldn't get graalvm to compile because it couldn't find "stdio.h". I'm stumped. – Evan Zheng Jun 02 '20 at 22:08
  • That means you don't have `cl` or it is not in the path. VS should do that for you. Restart the x64 terminal, and start it again as an admin. – José Pereda Jun 02 '20 at 22:16
  • @JoséPereda I've tried opening x64 native tools again in admin mode. With or without putting cl manually on the system path, it still gives me an error. I've updated the post with the error that happens when cl is on the path. Nothing I think of seems to be working. – Evan Zheng Jun 02 '20 at 22:33
  • You shouldn't need to add `cl` to the path. VS should do that for you. When you run `echo %PATH` from the x64 command line, it should print several lines with all the VS stuff. – José Pereda Jun 02 '20 at 22:52
  • Okay, for some reason when I update from 14.25 to 14.26 the problem goes away. – Evan Zheng Jun 03 '20 at 17:03
  • Problem still there in 14.27. Can somebody tell, what is root cause of the problem? – AbsoluteDev Oct 31 '20 at 19:54

2 Answers2

3

I've had the same two issues:

  1. No cl operations possible
  2. stdio.h or similar file cannot be found

Solution for the first issue (author did already):

Make sure the system path contains the Visual Studio entry. Something like "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\bin\HostX64\x64"

Visual Studio seems to miss the entry on the path variable sometimes on installation. I had it installed to a different directory. That might cause the problem.

Solution for the second issue:

The documentation states that you have to run all maven or gradle commands in the Native Tools Command Prompt if running on Windows. I missed that part a few times while reading the docs.

If you are running on Windows, you need to run all the Client goals from an x64 terminal.

After that i was able to use the client:compile and client:link goals.

Pascal P.
  • 54
  • 5
0

I'm using IntelliJ idea. As it mentioned in Gluon Documentation,"All build commands, be it with Maven or Gradle, must be executed in a Visual Studio 2019 Command Prompt called x64 Native Tools Command Prompt for VS 2019". Firstly, find terminal (ALT+f12) in IntelliJ. Locate to the root directory of your module. Type "cmd.exe /k "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat", which in my case is "cmd.exe /k "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat". Run it. Secondly, run "mvn gluonfx:compile". Here is the result. Holp it will solute your problem.

潘亚杰
  • 1
  • 2
  • 1
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Apr 19 '23 at 07:37