javafxgluongraalvm-native-image

Can't run mvn gluonfx:link goal to create native image


I just want to produce the native image for Windows platform from example Gluon project, but I get an error. I already install all the requirements. When run mvn gluonfx:compile I get no error, but when I run mvn gluonfx:link, I get this error:

[ERROR] Failed to execute goal com.gluonhq:gluonfx-maven-plugin:1.0.1:link (default-cli) on project hellogluonstart: Linking failed -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.gluonhq:gluonfx-maven-plugin:1.0.1:link (default-cli) on project hellogluonstart: Linking failed
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    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:956)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    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: org.apache.maven.plugin.MojoExecutionException: Linking failed
    at com.gluonhq.NativeLinkMojo.execute (NativeLinkMojo.java:54)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    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:956)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    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)

This is the log error from a log file:

Creating library C:\Dev\Exercise\Gluon-Lab\gluon-samples-master\HelloFX\target\gluonfx\x86_64-windows\HelloFX.lib and object C:\Dev\Exercise\Gluon-Lab\gluon-samples-master\HelloFX\target\gluonfx\x86_64-windows\HelloFX.exp
    net.lib(DefaultProxySelector.obj) : error LNK2019: unresolved external symbol __imp_WinHttpOpen referenced in function Java_sun_net_spi_DefaultProxySelector_init
    net.lib(DefaultProxySelector.obj) : error LNK2019: unresolved external symbol __imp_WinHttpGetProxyForUrl referenced in function Java_sun_net_spi_DefaultProxySelector_getSystemProxies
    net.lib(DefaultProxySelector.obj) : error LNK2019: unresolved external symbol __imp_WinHttpGetIEProxyConfigForCurrentUser referenced in function Java_sun_net_spi_DefaultProxySelector_getSystemProxies
    C:\Dev\Exercise\Gluon-Lab\gluon-samples-master\HelloFX\target\gluonfx\x86_64-windows\HelloFX.exe : fatal error LNK1120: 3 unresolved externals

Solution

  • Thank José Pereda for giving the hint to solve this error with this GitHub issue.

    First, we need to add the plugin repository to the pom:

    <project>
        ...
        <pluginRepositories>
            ...
            <pluginRepository>
                <id>sonatype</id>
                <url>http://oss.sonatype.org/content/repositories/snapshots/</url>
            </pluginRepository>
            ...
        </pluginRepositories>
        ...
    </project>
    

    And then change just the gluonfx-maven-plugin version to 1.0.2-SNAPSHOT. Finally, just try to build again.