Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Native Image] Got 2 unresolved external symbol while building Native Image #10426

Open
1 task
MoritzArena opened this issue Jan 7, 2025 · 6 comments
Open
1 task
Assignees

Comments

@MoritzArena
Copy link

Describe the Issue

I am adapting GraalVM for Nacos. In the past, I was able to successfully package the Native Image binary program through GraalVM on the Windows 11 platform. However, after I upgraded Visual Studio, a build error occurred. Specifically, it was missing two link symbols:

  1. __imp_SHGetFolderPathW referenced in function getHomeFromShell32
  2. SHGetKnownFolderPath referenced in function getHomeFromShell32

These problems only occur on the Windows 11 platform. The binary file can be packaged normally on Linux. My environment information is as follows:

Name Value
Java version 17.0.13+10-LTS
Vendor version Oracle GraalVM 17.0.13+10.1
Runtime version 17.0.13+10-LTS-jvmci-23.0-b49
C compiler cl.exe (microsoft, x64, 19.42.34435)

Please confirm if you have tested with the latest available version.

Share the svm_err_b_*.md File

svm_err_b_20250107T234343.404_pid9276.md

Additional Context

No response

@selhagani
Copy link
Member

Hi @MoritzArena,

Thank you for reaching out to us about this. Could you please provide us with a reproducer alongside the steps needed to encounter the issue?

@MoritzArena
Copy link
Author

Hi @MoritzArena,

Thank you for reaching out to us about this. Could you please provide us with a reproducer alongside the steps needed to encounter the issue?

No problem, the relevant code has been pushed to the official repository of nacos. You can build the GraalVM binary file by following the steps below:

  1. clone https://github.com/alibaba/nacos.git
  2. switch git branch to summer-ospp#12028
  3. run command mvn clean install -Pnative -Pnative-win64 -DskipTests=true

I encountered a build problem in the following environment:

Name Value
OS version Windows 11 Pro 24H2 26100.2605
Java version 17.0.13+10-LTS
Vendor version Oracle GraalVM 17.0.13+10.1
Runtime version 17.0.13+10-LTS-jvmci-23.0-b49
C compiler cl.exe (microsoft, x64, 19.42.34435)
Visual Studio Community version 2022 17.12.3
Visual Studio Build Tools version 2019 16.11.42
Windows 11 SDK version 10.0.22621.0

I have encountered this problem on Windows 11 before. Later, I reinstalled my operating system and reinstalled all the environments, but I still encountered this problem.

@selhagani selhagani self-assigned this Jan 8, 2025
@selhagani
Copy link
Member

I just tested on my machine using the sa,e visual studio version and GraalVM version as you did but I am getting a different error:

========================================================================================================================
For detailed information and explanations on the build output, visit:
https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/BuildOutput.md
------------------------------------------------------------------------------------------------------------------------
[1/8] Initializing...                                                                                   (19.7s @ 0.59GB)
 Java version: 17.0.13+10-LTS, vendor version: Oracle GraalVM 17.0.13+10.1
 Graal compiler: optimization level: 2, target machine: x86-64-v3, PGO: ML-inferred
 C compiler: cl.exe (microsoft, x64, 19.42.34435)
 Garbage collector: Serial GC (max heap size: 80% of RAM)
 2 user-specific feature(s)
 - com.oracle.svm.thirdparty.gson.GsonFeature
 - org.springframework.aot.nativex.feature.PreComputeFieldFeature
SLF4J(W): No SLF4J providers were found.
SLF4J(W): Defaulting to no-operation (NOP) logger implementation
SLF4J(W): See https://www.slf4j.org/codes.html#noProviders for further details.
[2/8] Performing analysis...  [******]                                                                  (53.6s @ 3.97GB)
  30,011 (91.84%) of 32,676 types reachable
  54,686 (69.49%) of 78,697 fields reachable
 180,621 (66.63%) of 271,099 methods reachable
  10,081 types, 4,100 fields, and 24,971 methods registered for reflection
     136 types,   285 fields, and    90 methods registered for JNI access
       5 native libraries: crypt32, ncrypt, psapi, version, winhttp

Error: type is not available in this platform: com.oracle.svm.hosted.NativeImageGeneratorRunner
Detailed message:
Trace: Object was reached by
  reading static field sun.launcher.LauncherHelper.appClass
    at <unknown-location>
  registered as read because: it is registered for as JNI accessed

Error: Use -H:+ReportExceptionStackTraces to print stacktrace of underlying exception
------------------------------------------------------------------------------------------------------------------------
                        8.3s (11.1% of total time) in 64 GCs | Peak RSS: 7.69GB | CPU load: 6.59
========================================================================================================================
Finished generating 'nacos-server' in 1m 13s.
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for Alibaba NACOS 2.5.0-SNAPSHOT 2.5.0-SNAPSHOT:
[INFO]
[INFO] Alibaba NACOS 2.5.0-SNAPSHOT ....................... SUCCESS [  6.081 s]
[INFO] nacos-api 2.5.0-SNAPSHOT ........................... SUCCESS [ 10.629 s]
[INFO] nacos-common 2.5.0-SNAPSHOT ........................ SUCCESS [ 12.061 s]
[INFO] nacos-consistency 2.5.0-SNAPSHOT ................... SUCCESS [  7.095 s]
[INFO] nacos-plugin 2.5.0-SNAPSHOT ........................ SUCCESS [  0.373 s]
[INFO] nacos-datasource-plugin 2.5.0-SNAPSHOT ............. SUCCESS [  3.208 s]
[INFO] nacos-custom-environment-plugin 2.5.0-SNAPSHOT ..... SUCCESS [  1.183 s]
[INFO] nacos-sys 2.5.0-SNAPSHOT ........................... SUCCESS [  3.241 s]
[INFO] nacos-persistence 2.5.0-SNAPSHOT ................... SUCCESS [  3.902 s]
[INFO] nacos-auth-plugin 2.5.0-SNAPSHOT ................... SUCCESS [  1.598 s]
[INFO] nacos-auth 2.5.0-SNAPSHOT .......................... SUCCESS [  2.434 s]
[INFO] nacos-trace-plugin 2.5.0-SNAPSHOT .................. SUCCESS [  1.118 s]
[INFO] nacos-control-plugin 2.5.0-SNAPSHOT ................ SUCCESS [  2.862 s]
[INFO] nacos-core 2.5.0-SNAPSHOT .......................... SUCCESS [ 13.033 s]
[INFO] nacos-encryption-plugin 2.5.0-SNAPSHOT ............. SUCCESS [  1.181 s]
[INFO] nacos-config-plugin 2.5.0-SNAPSHOT ................. SUCCESS [  1.209 s]
[INFO] nacos-config 2.5.0-SNAPSHOT ........................ SUCCESS [ 13.143 s]
[INFO] nacos-cmdb 2.5.0-SNAPSHOT .......................... SUCCESS [  1.808 s]
[INFO] nacos-naming 2.5.0-SNAPSHOT ........................ SUCCESS [ 13.134 s]
[INFO] nacos-address 2.5.0-SNAPSHOT ....................... SUCCESS [  2.477 s]
[INFO] nacos-logger-adapter-impl 2.5.0-SNAPSHOT ........... SUCCESS [  0.425 s]
[INFO] nacos-logback-adapter-12 2.5.0-SNAPSHOT ............ SUCCESS [  1.359 s]
[INFO] nacos-log4j2-adapter 2.5.0-SNAPSHOT ................ SUCCESS [  1.318 s]
[INFO] nacos-client 2.5.0-SNAPSHOT ........................ SUCCESS [  8.943 s]
[INFO] nacos-plugin-default-impl 2.5.0-SNAPSHOT ........... SUCCESS [  0.255 s]
[INFO] nacos-default-auth-plugin 2.5.0-SNAPSHOT ........... SUCCESS [  5.076 s]
[INFO] nacos-default-control-plugin 2.5.0-SNAPSHOT ........ SUCCESS [  1.227 s]
[INFO] nacos-default-plugin-all ........................... SUCCESS [  0.582 s]
[INFO] nacos-istio 2.5.0-SNAPSHOT ......................... SUCCESS [ 15.555 s]
[INFO] nacos-prometheus 2.5.0-SNAPSHOT .................... SUCCESS [  2.483 s]
[INFO] nacos-console 2.5.0-SNAPSHOT ....................... FAILURE [01:48 min]
[INFO] nacos-test 2.5.0-SNAPSHOT .......................... SKIPPED
[INFO] nacos-config-test 2.5.0-SNAPSHOT ................... SKIPPED
[INFO] nacos-naming-test 2.5.0-SNAPSHOT ................... SKIPPED
[INFO] nacos-core-test 2.5.0-SNAPSHOT ..................... SKIPPED
[INFO] nacos-example 2.5.0-SNAPSHOT ....................... SKIPPED
[INFO] nacos-distribution 2.5.0-SNAPSHOT .................. SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  04:08 min
[INFO] Finished at: 2025-01-09T11:59:41+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.graalvm.buildtools:native-maven-plugin:0.10.2:compile-no-fork (build-native) on project nacos-console: Execution of C:\Users\Soufiane\Downloads\graalvm-java17-windows-amd64-23.0.6-signed\graalvm-jdk-17.0.13+10.1\bin\native-image.cmd @target\tmp\native-image-5375471155757403052.args returned non-zero result -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.graalvm.buildtools:native-maven-plugin:0.10.2:compile-no-fork (build-native) on project nacos-console: Execution of C:\Users\Soufiane\Downloads\graalvm-java17-windows-amd64-23.0.6-signed\graalvm-jdk-17.0.13+10.1\bin\native-image.cmd @target\tmp\native-image-5375471155757403052.args returned non-zero result
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:333)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
    at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
    at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
    at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:903)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:280)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:203)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:568)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:255)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:201)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:361)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:314)
Caused by: org.apache.maven.plugin.MojoExecutionException: Execution of C:\Users\Soufiane\Downloads\graalvm-java17-windows-amd64-23.0.6-signed\graalvm-jdk-17.0.13+10.1\bin\native-image.cmd @target\tmp\native-image-5375471155757403052.args returned non-zero result
    at org.graalvm.buildtools.maven.AbstractNativeImageMojo.buildImage (AbstractNativeImageMojo.java:429)
    at org.graalvm.buildtools.maven.NativeCompileNoForkMojo.execute (NativeCompileNoForkMojo.java:104)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
    at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
    at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
    at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:903)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:280)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:203)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:568)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:255)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:201)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:361)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:314)
[ERROR]
[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
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <args> -rf :nacos-console
[DEBUG] Shutting down adapter factory; available factories [file-lock, rwlock-local, semaphore-local, noop]; available name mappers [discriminating, file-gav, file-hgav, file-static, gav, static]
[DEBUG] Shutting down 'file-lock' factory
[DEBUG] Shutting down 'rwlock-local' factory
[DEBUG] Shutting down 'semaphore-local' factory
[DEBUG] Shutting down 'noop' factory ```

Do you have any idea what I might be missing here?

@MoritzArena
Copy link
Author

I am using Maven 3.9.9 for building, and I am not sure if the issue you encountered is caused by a mismatch between the Maven version and the native-maven-plugin.

@selhagani
Copy link
Member

I just tested using Maven 3.9.9 yet I'm still getting the same error unfortunately

@MoritzArena
Copy link
Author

Thank you for taking the time to test this issue. Based on what we know so far, it seems that the issue you encountered is not related to the Maven version. Additionally, we are using GraalVM JDK 17 downloaded from Oracle, with the version information: Oracle GraalVM 17.0.13+10.1 (build 17.0.13+10-LTS-jvmci-23.0-b49). I'm not sure if this differs from the GraalVM version you are testing. However, we can be certain that during our testing, we encountered errors related to missing symbol links.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants