gluonhq / gluonfx-maven-plugin

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

gluonfx link error LNK2001 Java_jdk_net_WindowsSocketOptions #456

Open JiHongYuan opened 1 year ago

JiHongYuan commented 1 year ago

Hello

use idea invoke gluonfx:link

This is the logs

Process
=======
link

Command Line
============
link F:\idea_workspace\Chat\chat-client\target\gluonfx\x86_64-windows\gvm\chat-client\launcher.obj F:\idea_workspace\Chat\chat-client\target\gluonfx\x86_64-windows\gvm\tmp\SVM-1675328642016\org.github.jhy.chat.client.app.obj F:\idea_workspace\Chat\chat-client\target\gluonfx\x86_64-windows\gvm\chat-client\IconGroup.obj j2pkcs11.lib java.lib net.lib nio.lib prefs.lib fdlibm.lib zip.lib sunmscapi.lib jvm.lib libchelper.lib advapi32.lib iphlpapi.lib secur32.lib userenv.lib version.lib ws2_32.lib winhttp.lib ncrypt.lib crypt32.lib /NODEFAULTLIB:libcmt.lib /SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup comdlg32.lib dwmapi.lib gdi32.lib imm32.lib shell32.lib uiautomationcore.lib urlmon.lib winmm.lib glass.lib javafx_font.lib javafx_iio.lib prism_common.lib prism_d3d.lib /WHOLEARCHIVE:glass.lib /WHOLEARCHIVE:javafx_font.lib /WHOLEARCHIVE:javafx_iio.lib /WHOLEARCHIVE:prism_common.lib /WHOLEARCHIVE:prism_d3d.lib /OUT:F:\idea_workspace\Chat\chat-client\target\gluonfx\x86_64-windows\chat-client.exe /LIBPATH:C:\Users\JHY\.gluon\substrate\javafxStaticSdk\20-ea+7\windows-x86_64\sdk\lib /LIBPATH:C:\Users\JHY\.jdks\graalvm-ce-19\lib\svm\clibraries\windows-amd64 /LIBPATH:C:\Users\JHY\.jdks\graalvm-ce-19\lib\static\windows-amd64

Output
======
Microsoft (R) Incremental Linker Version 14.34.31937.0
Copyright (C) Microsoft Corporation.  All rights reserved.

   Creating library F:\idea_workspace\Chat\chat-client\target\gluonfx\x86_64-windows\chat-client.lib and object F:\idea_workspace\Chat\chat-client\target\gluonfx\x86_64-windows\chat-client.exp
org.github.jhy.chat.client.app.obj : error LNK2001: unresolved external symbol Java_com_sun_management_internal_OperatingSystemImpl_initialize0
org.github.jhy.chat.client.app.obj : error LNK2001: unresolved external symbol Java_jdk_net_WindowsSocketOptions_getIpDontFragment0
org.github.jhy.chat.client.app.obj : error LNK2001: unresolved external symbol Java_jdk_net_WindowsSocketOptions_setIpDontFragment0
F:\idea_workspace\Chat\chat-client\target\gluonfx\x86_64-windows\chat-client.exe : fatal error LNK1120: 3 unresolved externals

Result
======
result: 1120

first error Java_com_sun_management_internal_OperatingSystemImpl_initialize0 i use this https://github.com/gluonhq/substrate/issues/1163 This is the logs:

Process
=======
link

Command Line
============
link F:\idea_workspace\Chat\chat-client\target\gluonfx\x86_64-windows\gvm\chat-client\launcher.obj F:\idea_workspace\Chat\chat-client\target\gluonfx\x86_64-windows\gvm\tmp\SVM-1675328642016\org.github.jhy.chat.client.app.obj F:\idea_workspace\Chat\chat-client\target\gluonfx\x86_64-windows\gvm\chat-client\IconGroup.obj j2pkcs11.lib java.lib net.lib nio.lib prefs.lib fdlibm.lib zip.lib sunmscapi.lib jvm.lib libchelper.lib advapi32.lib iphlpapi.lib secur32.lib userenv.lib version.lib ws2_32.lib winhttp.lib ncrypt.lib crypt32.lib /NODEFAULTLIB:libcmt.lib /SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup comdlg32.lib dwmapi.lib gdi32.lib imm32.lib shell32.lib uiautomationcore.lib urlmon.lib winmm.lib glass.lib javafx_font.lib javafx_iio.lib prism_common.lib prism_d3d.lib /WHOLEARCHIVE:glass.lib /WHOLEARCHIVE:javafx_font.lib /WHOLEARCHIVE:javafx_iio.lib /WHOLEARCHIVE:prism_common.lib /WHOLEARCHIVE:prism_d3d.lib /OUT:F:\idea_workspace\Chat\chat-client\target\gluonfx\x86_64-windows\chat-client.exe /LIBPATH:C:\Users\JHY\.gluon\substrate\javafxStaticSdk\20-ea+7\windows-x86_64\sdk\lib /LIBPATH:C:\Users\JHY\.jdks\graalvm-ce-19\lib\svm\clibraries\windows-amd64 /LIBPATH:C:\Users\JHY\.jdks\graalvm-ce-19\lib\static\windows-amd64 management_ext.lib psapi.lib

Output
======
Microsoft (R) Incremental Linker Version 14.34.31937.0
Copyright (C) Microsoft Corporation.  All rights reserved.

   Creating library F:\idea_workspace\Chat\chat-client\target\gluonfx\x86_64-windows\chat-client.lib and object F:\idea_workspace\Chat\chat-client\target\gluonfx\x86_64-windows\chat-client.exp
org.github.jhy.chat.client.app.obj : error LNK2001: unresolved external symbol Java_jdk_net_WindowsSocketOptions_getIpDontFragment0
org.github.jhy.chat.client.app.obj : error LNK2001: unresolved external symbol Java_jdk_net_WindowsSocketOptions_setIpDontFragment0
F:\idea_workspace\Chat\chat-client\target\gluonfx\x86_64-windows\chat-client.exe : fatal error LNK1120: 2 unresolved externals

Result
======
result: 1120

Java_jdk_net_WindowsSocketOptions_getIpDontFragment0Java_jdk_net_WindowsSocketOptions_setIpDontFragment0 no solution was found.

Thanks for your help

My configuration is :

idea windows 10 image image

I use the maven configuration:

<plugin>
    <groupId>com.gluonhq</groupId>
    <artifactId>gluonfx-maven-plugin</artifactId>
    <version>1.0.16</version>
    <configuration>
        <target>host</target>
        <nativeImageArgs>
            <arg>--allow-incomplete-classpath</arg>
            <arg>--trace-class-initialization=ch.qos.logback.classic.Logger</arg>
            <arg>--trace-object-instantiation=ch.qos.logback.core.AsyncAppenderBase$Worker</arg>
            <arg>--initialize-at-build-time=org.slf4j.LoggerFactory,ch.qos.logback</arg>
            <arg>--initialize-at-run-time=io.netty</arg>
        </nativeImageArgs>
        <graalvmHome>C:\Users\JHY\.jdks\graalvm-ce-19</graalvmHome>
        <mainClass>org.github.jhy.chat.client.App</mainClass>
    </configuration>
</plugin>
ennerf commented 1 year ago

It looks like WindowsSocketOptions.java requires the extnet library. The IP_DONTFRAGMENT option wasn't added until Java19 (see JDK-8285224), so it wouldn't be surprising to not be included by the default until the next LTS release. I assume C:\Users\JHY\.jdks\graalvm-ce-19 is the 22.3.1 with JDK19 rather than an old graalvm-19?

You could also define a placeholder stub that does nothing.

SaptarshiSarkar12 commented 1 year ago

@JiHongYuan @ennerf Has this issue got resolved as I am also facing the same error?