Open RealThanhpv opened 1 year ago
This can be fix by explicitly targeting org.graalvm.nativeimage.Platform$DARWIN_MACOS (my machine)
This can be fix by explicitly targeting org.graalvm.nativeimage.Platform$DARWIN_MACOS
@RealThanhpv It did not work for me. Am I making any mistake? Please check the pom.xml file of my project and let me know if you can help me fix the error.
I do not like my solution, it is a kind of hard-code, and that is for my specific machine (arch). However you may miss the dependency of org.graalvm.sdk. You my need to choose the right one for you machine from org.graalvm.nativeimage.Platform.*
I do not like my solution, it is a kind of hard-code, and that is for my specific machine (arch). However you may miss the dependency of org.graalvm.sdk. You my need to choose the right one for you machine from org.graalvm.nativeimage.Platform.*
@RealThanhpv Okay, so, I am using GitHub actions to perform the build process and it has x86_64 architecture and runs macOS 12 with XCode 14. but, **how do I specify the right one for this runner from org.graalvm.nativeimage.Platform.***?
I meant the target machine is my local machine so the arch is specific so I can hard-code. You are building with GitHub action on remote machine, I do not know how to be specific about the arch there but only os. I think you should get it succeed on local machine first.
I meant the target machine is my local machine so the arch is specific so I can hard-code. You are building with GitHub action on remote machine, I do not know how to know the arch there but only os.
@RealThanhpv I mentioned that the macOS runner is having x86_64 architecture. So, isn't there any solution for that kind of machine? Also, I am not having a mac with that same architecture. So, I can't even predict what might be the solution. Even the documentation does not specify about this error :weary: .
You may put these deps and try again with the hard-code of org.graalvm.nativeimage.Platform$DARWIN_MACOS
I not currently building on Mac, I got it built a few months ago.
<!-- https://mvnrepository.com/artifact/org.graalvm.nativeimage/library-support -->
<dependency>
<groupId>org.graalvm.nativeimage</groupId>
<artifactId>library-support</artifactId>
<version>23.0.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.graalvm.sdk/graal-sdk -->
<dependency>
<groupId>org.graalvm.sdk</groupId>
<artifactId>graal-sdk</artifactId>
<version>23.0.1</version>
</dependency>
I followed the error to find this info, may be helpful for you:
module org.graalvm.sdk {
requires java.logging;
exports com.oracle.svm.core.annotate;
exports org.graalvm.collections;
exports org.graalvm.home;
exports org.graalvm.home.impl;
exports org.graalvm.nativeimage;
exports org.graalvm.nativeimage.c;
exports org.graalvm.nativeimage.c.constant;
exports org.graalvm.nativeimage.c.function;
exports org.graalvm.nativeimage.c.struct;
exports org.graalvm.nativeimage.c.type;
exports org.graalvm.nativeimage.hosted;
exports org.graalvm.nativeimage.impl to com.oracle.svm.svm_enterprise, org.graalvm.extraimage.builder, org.graalvm.nativeimage.base, org.graalvm.nativeimage.builder, org.graalvm.nativeimage.configure, org.graalvm.nativeimage.pointsto;
exports org.graalvm.nativeimage.impl.clinit to org.graalvm.nativeimage.builder;
exports org.graalvm.options;
exports org.graalvm.polyglot;
exports org.graalvm.polyglot.impl to com.oracle.graal.graal_enterprise, org.graalvm.truffle;
exports org.graalvm.polyglot.io;
exports org.graalvm.polyglot.management;
exports org.graalvm.polyglot.proxy;
exports org.graalvm.word;
exports org.graalvm.word.impl to jdk.internal.vm.compiler;
uses org.graalvm.home.HomeFinder;
uses org.graalvm.nativeimage.Platform;
uses org.graalvm.polyglot.impl.AbstractPolyglotImpl;
opens org.graalvm.polyglot to org.graalvm.truffle;
provides org.graalvm.home.HomeFinder with org.graalvm.home.impl.DefaultHomeFinder;
provides org.graalvm.nativeimage.Platform with org.graalvm.nativeimage.Platform.MACOS_AMD64, org.graalvm.nativeimage.Platform.IOS_AMD64, org.graalvm.nativeimage.Platform.ANDROID_AARCH64, org.graalvm.nativeimage.Platform.LINUX_RISCV64, org.graalvm.nativeimage.Platform.IOS_AARCH64, org.graalvm.nativeimage.Platform.WINDOWS_AARCH64, org.graalvm.nativeimage.Platform.MACOS_AARCH64, org.graalvm.nativeimage.Platform.WINDOWS_AMD64, org.graalvm.nativeimage.Platform.LINUX_AARCH64, org.graalvm.nativeimage.Platform.LINUX_AMD64;
}
You may put these deps and try again with the hard-code of org.graalvm.nativeimage.Platform$DARWIN_MACOS
I not currently building on Mac, I got it built a few months ago.
<!-- https://mvnrepository.com/artifact/org.graalvm.nativeimage/library-support --> <dependency> <groupId>org.graalvm.nativeimage</groupId> <artifactId>library-support</artifactId> <version>23.0.1</version> </dependency> <!-- https://mvnrepository.com/artifact/org.graalvm.sdk/graal-sdk --> <dependency> <groupId>org.graalvm.sdk</groupId> <artifactId>graal-sdk</artifactId> <version>23.0.1</version> </dependency>
@RealThanhpv I tried with these dependencies just now, but, the build failed with the same error message. I think that there is some problem in the org.graalvm.nativeimage.Platform$DARWIN_AMD64 java interface. GluonFX is failing to make an instance of that class. So, problem might lie with GluonFX SDK.
It could not initiate org.graalvm.nativeimage.Platform$DARWIN_AMD64. DARWIN_AMD64 is not provided. So target MACOS_AMD64 with this
<nativeImageArg>-Dsvm.platform=org.graalvm.nativeimage.Platform$MACOS_AMD64</nativeImageArg>
in your pom.xml
look at this module org.graalvm.sdk
you can see org.graalvm.nativeimage.Platform
is provided as below:
provides org.graalvm.nativeimage.Platform with org.graalvm.nativeimage.Platform.MACOS_AMD64, org.graalvm.nativeimage.Platform.IOS_AMD64, org.graalvm.nativeimage.Platform.ANDROID_AARCH64, org.graalvm.nativeimage.Platform.LINUX_RISCV64, org.graalvm.nativeimage.Platform.IOS_AARCH64, org.graalvm.nativeimage.Platform.WINDOWS_AARCH64, org.graalvm.nativeimage.Platform.MACOS_AARCH64, org.graalvm.nativeimage.Platform.WINDOWS_AMD64, org.graalvm.nativeimage.Platform.LINUX_AARCH64, org.graalvm.nativeimage.Platform.LINUX_AMD64;
@RealThanhpv It worked for macOS but, in the link task, it failed for windows. The below is the error for link task on windows.
[Mon Aug 14 15:04:50 UTC 2023][INFO] [SUB] Creating library D:\a\Drifty\Drifty\target\gluonfx\x86_64-windows\Drifty.lib and object D:\a\Drifty\Drifty\target\gluonfx\x86_64-windows\Drifty.exp
[Mon Aug 14 15:04:50 UTC 2023][INFO] [SUB] gui.launcher.obj : error LNK2001: unresolved external symbol Java_jdk_net_WindowsSocketOptions_getIpDontFragment0
[Mon Aug 14 15:04:50 UTC 2023][INFO] [SUB] gui.launcher.obj : error LNK2001: unresolved external symbol Java_jdk_net_WindowsSocketOptions_setIpDontFragment0
[Mon Aug 14 15:04:50 UTC 2023][INFO] [SUB] nio.lib(FileDispatcherImpl.obj) : error LNK2019: unresolved external symbol TransmitFile referenced in function Java_sun_nio_ch_FileDispatcherImpl_transferTo0
[Mon Aug 14 15:04:50 UTC 2023][INFO] [SUB] D:\a\Drifty\Drifty\target\gluonfx\x86_64-windows\Drifty.exe : fatal error LNK1120: 3 unresolved externals
[Mon Aug 14 15:04:50 UTC 2023][SEVERE] Process link failed with result: 1120
Can you please help me in this? I would appreciate your help.
Follow this: https://github.com/gluonhq/gluonfx-maven-plugin/issues/456#issuecomment-1524896369 You may need create profiles for Windows, MacOs, Linux accordingly for the link tasks.
Follow this: #456 (comment) You may need create profiles for Windows, MacOs, Linux accordingly for the link tasks.
Yes @RealThanhpv, I have read that. But, I could not understand how to implement the fix. How would I add the linker arg? Can you show me a configuration example? I have found that the WindowsSocketOptions class is under jdk.net.ExtendedSocketOptions which creates an instance of that private/protected WindowsSocketOptions class.
My pom.xml file is here. You can see I have created separate profiles for each OS-specific GUI build task.
add this to properties section in pom
<dump.link>missing_symbols_win64.o</dump.link>
add this to gluonfx-maven-plugin configuration section
<linkerArgs>
<arg>${dumb.link}</arg>
</linkerArgs>
Use your gcc to compile this c code to get missing_symbols_win64.o
and place it in project dir.
#include <stdlib.h>
void Java_jdk_net_WindowsSocketOptions_getIpDontFragment0(){} void Java_jdk_net_WindowsSocketOptions_setIpDontFragment0(){} void TransmitFile(){} void Java_com_sun_management_internal_OperatingSystemImpl_initialize0(){} void _Java_com_sun_management_internal_OperatingSystemImpl_initialize0(){}
4. Compile it on mac, linux as well and define `dumb.link` for each platform, in the profiles . It is not allowed to attach .o files here so I can't share my builds.
@RealThanhpv Should I place the missing_symbols_win64.o
file in src directory or project root?
Also, is it necessary to make this files for the other two OS?
@RealThanhpv When I run the gcc missing_symbols_win64.c
command, it gave me the following error -
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/12/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x1b): undefined reference to `main'
collect2: error: ld returned 1 exit status
How can I solve this? I think a main method is required, right?
@RealThanhpv Should I place the
missing_symbols_win64.o
file in src directory or project root? Also, is it necessary to make this files for the other two OS?
Yes. You compile a c code file into object files for platforms, accordingly. Those are platform dependent. So you should rename it. Google for compiling a C file to object files for platforms.
You put it where ever you want as long as the linker can find for the link task. I made my simple choice.
@RealThanhpv When I run the
gcc missing_symbols_win64.c
command, it gave me the following error -/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/12/../../../x86_64-linux-gnu/Scrt1.o: in function `_start': (.text+0x1b): undefined reference to `main' collect2: error: ld returned 1 exit status
How can I solve this? I think a main method is required, right?
No. It is not an executable file, It is an object file. Compile it to .o file not .exe file.
@RealThanhpv Okay, so, let me try it. Thank you for the help :smile: !
@RealThanhpv It worked! Thank you for your immense help :slightly_smiling_face: !
Welcome to JavaFX native image :)
Hi I am not sure this the plugin or graalvm
MacOs Monterey, Intel Corei5