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

Objectfile resolution failure #485

Open
SaptarshiSarkar12 opened this issue Sep 4, 2023 · 2 comments
Open

Objectfile resolution failure #485

SaptarshiSarkar12 opened this issue Sep 4, 2023 · 2 comments

Comments

@SaptarshiSarkar12
Copy link

I was building a JavaFX app for Drifty project. I am using GluonFX-Maven-Plugin to build native images for the app.

Problem

  • A problem arises when I pass -o Drifty GUI as a native-image arg in the plugin configuration.
  • The GraalVM part of the plugin's process runs smooth. But, after this step, the plugin tries to find a C object with the name identical to the main class name, which it fails to find. Hence, it throws an error as shown below -
[Sat Sep 02 21:17:13 IST 2023][INFO] Additional information: Objectfile should be called gui.forms.main.o but we didn't find that under /home/saptarshi-sarkar/Drifty/target/gluonfx/x86_64-linux/gvm
[Sat Sep 02 21:17:13 IST 2023][SEVERE] Compiling failed.

Possible Solution

A feature can be included in the plugin to get the name of the App (in this case Drifty GUI) from the pom file, and search for it in the target directory.

My pom.xml file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.Drifty</groupId>
    <artifactId>Drifty</artifactId>
    <version>2.0.0</version>
    <name>Drifty</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <junit.version>5.10.0</junit.version>
        <javafx.version>20</javafx.version>
        <gluonfx-maven-plugin.version>1.0.19</gluonfx-maven-plugin.version>
        <native-maven-plugin.version>0.9.23</native-maven-plugin.version>
        <guiMain>GUI.Forms.Main</guiMain>
        <cliMain>CLI.Drifty_CLI</cliMain>
        <package.type/>
        <mac.app.store/>
        <resource-config-file/>
        <system-native-image-arg/>
        <system-linker-arg/>
        <versions-maven-plugin>2.15.0</versions-maven-plugin>
        <maven-compiler-plugin>3.11.0</maven-compiler-plugin>
        <javafx-maven-plugin>0.0.8</javafx-maven-plugin>
    </properties>

    <!--
    To package:
    mvn clean -Pbuild-drifty-gui-for-macos-latest gluonfx:build gluonfx:package
    -->
    <dependencies>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>${javafx.version}</version>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.yaml</groupId>
            <artifactId>snakeyaml</artifactId>
            <version>2.2</version>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.13.0</version>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.10.1</version>
        </dependency>
        <dependency>
            <groupId>org.hildan.fxgson</groupId>
            <artifactId>fx-gson</artifactId>
            <version>5.0.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-text</artifactId>
            <version>1.10.0</version>
        </dependency>
        <dependency>
            <groupId>org.buildobjects</groupId>
            <artifactId>jproc</artifactId>
            <version>2.8.2</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <!--Maven Compiler Plugin-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven-compiler-plugin}</version>
                <configuration>
                    <source>20</source>
                    <target>20</target>
                </configuration>
            </plugin>
            <!--Maven Versions Plugin-->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>versions-maven-plugin</artifactId>
                <version>${versions-maven-plugin}</version>
            </plugin>
            <!--JavaFX Maven Plugin-->
            <plugin>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-maven-plugin</artifactId>
                <version>${javafx-maven-plugin}</version>
                <configuration>
                    <mainClass>${guiMain}</mainClass>
                </configuration>
            </plugin>
            <!-- GUI native image builder plugin-->
            <plugin>
                <groupId>com.gluonhq</groupId>
                <artifactId>gluonfx-maven-plugin</artifactId>
                <version>${gluonfx-maven-plugin.version}</version>
                <configuration>
                    <mainClass>${guiMain}</mainClass>
                    <linkerArgs>
                        <arg>${system-linker-arg}</arg>
                    </linkerArgs>
                    <nativeImageArgs>
                        <arg>--enable-url-protocols=https</arg>
                        <arg>--enable-url-protocols=http</arg>
                        <arg>--no-fallback</arg>
                        <arg>--verbose</arg>
                        <arg>-H:ResourceConfigurationFiles=${pom.basedir}/config/${resource-config-file}</arg>
                        <arg>--add-exports=org.graalvm.nativeimage.builder/com.oracle.svm.core.jdk=ALL-UNNAMED</arg>
                        <arg>-o Drifty GUI</arg>
                        <arg>${system-native-image-arg}</arg>
                    </nativeImageArgs>
                    <appIdentifier>Drifty GUI</appIdentifier>
                    <releaseConfiguration>
                        <vendor>Drifty</vendor>
                        <description>Drifty is an open-source interactive file downloader system</description>
                        <packageType>${package.type}</packageType>
                        <bundleShortVersion>${project.version}</bundleShortVersion>
                        <bundleVersion>${project.version}</bundleVersion>
                        <!-- for macOS/iOS -->
                        <skipSigning>true</skipSigning>
                    </releaseConfiguration>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <!-- [Windows] CLI native image builder profile -->
        <profile>
            <id>build-drifty-cli-for-windows-latest</id>
            <properties>
                <resource-config-file>resource-config-windows.json</resource-config-file>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.graalvm.buildtools</groupId>
                        <artifactId>native-maven-plugin</artifactId>
                        <version>${native-maven-plugin.version}</version>
                        <extensions>true</extensions>
                        <configuration>
                            <imageName>Drifty CLI</imageName>
                            <mainClass>${cliMain}</mainClass>
                            <outputDirectory>target/CLI/windows</outputDirectory>
                            <buildArgs>
                                <buildArg>--enable-url-protocols=https</buildArg>
                                <buildArg>--enable-url-protocols=http</buildArg>
                                <buildArg>-H:ResourceConfigurationFiles=${pom.basedir}/config/${resource-config-file}</buildArg>
                                <buildArg>--no-fallback</buildArg>
                                <buildArg>-H:+ReportExceptionStackTraces</buildArg>
                                <buildArg>--verbose</buildArg>
                            </buildArgs>
                        </configuration>
                        <executions>
                            <execution>
                                <id>build</id>
                                <goals>
                                    <goal>build</goal>
                                </goals>
                                <phase>package</phase>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <!-- [Linux] CLI native image builder profile -->
        <profile>
            <id>build-drifty-cli-for-ubuntu-latest</id>
            <properties>
                <resource-config-file>resource-config-linux.json</resource-config-file>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.graalvm.buildtools</groupId>
                        <artifactId>native-maven-plugin</artifactId>
                        <version>${native-maven-plugin.version}</version>
                        <extensions>true</extensions>
                        <configuration>
                            <imageName>Drifty CLI</imageName>
                            <mainClass>${cliMain}</mainClass>
                            <outputDirectory>target/CLI/linux</outputDirectory>
                            <buildArgs>
                                <buildArg>--enable-url-protocols=https</buildArg>
                                <buildArg>--enable-url-protocols=http</buildArg>
                                <buildArg>-H:ResourceConfigurationFiles=${pom.basedir}/config/${resource-config-file}</buildArg>
                                <buildArg>--no-fallback</buildArg>
                                <buildArg>-H:+ReportExceptionStackTraces</buildArg>
                                <buildArg>--verbose</buildArg>
                            </buildArgs>
                        </configuration>
                        <executions>
                            <execution>
                                <id>build</id>
                                <goals>
                                    <goal>build</goal>
                                </goals>
                                <phase>package</phase>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <!-- [macOS] CLI native image builder profile -->
        <profile>
            <id>build-drifty-cli-for-macos-latest</id>
            <properties>
                <resource-config-file>resource-config-mac.json</resource-config-file>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.graalvm.buildtools</groupId>
                        <artifactId>native-maven-plugin</artifactId>
                        <version>${native-maven-plugin.version}</version>
                        <extensions>true</extensions>
                        <configuration>
                            <imageName>Drifty CLI</imageName>
                            <mainClass>${cliMain}</mainClass>
                            <outputDirectory>target/CLI/macos</outputDirectory>
                            <buildArgs>
                                <buildArg>--enable-url-protocols=https</buildArg>
                                <buildArg>--enable-url-protocols=http</buildArg>
                                <buildArg>-H:ResourceConfigurationFiles=${pom.basedir}/config/${resource-config-file}</buildArg>
                                <buildArg>--no-fallback</buildArg>
                                <buildArg>-H:+ReportExceptionStackTraces</buildArg>
                                <buildArg>--verbose</buildArg>
                            </buildArgs>
                        </configuration>
                        <executions>
                            <execution>
                                <id>build</id>
                                <goals>
                                    <goal>build</goal>
                                </goals>
                                <phase>package</phase>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <!-- [macOS] GUI native image builder profile -->
        <profile>
            <id>build-drifty-gui-for-macos-latest</id>
            <properties>
                <package.type>pkg</package.type>
                <system-native-image-arg>-Dsvm.platform=org.graalvm.nativeimage.Platform$MACOS_AMD64</system-native-image-arg>
                <system-linker-arg>${pom.basedir}/config/missing_symbols-macos-latest.o</system-linker-arg>
                <resource-config-file>resource-config-mac.json</resource-config-file>
                <mac.app.store>true</mac.app.store>
            </properties>
        </profile>
        <!-- [Linux] GUI native image builder profile -->
        <profile>
            <id>build-drifty-gui-for-ubuntu-latest</id>
            <properties>
                <system-linker-arg>${pom.basedir}/config/missing_symbols-ubuntu-latest.o</system-linker-arg>
                <resource-config-file>resource-config-linux.json</resource-config-file>
            </properties>
        </profile>
        <!-- [Windows] GUI native image builder profile -->
        <profile>
            <id>build-drifty-gui-for-windows-latest</id>
            <properties>
                <package.type>msi</package.type>
                <system-linker-arg>${pom.basedir}/config/missing_symbols-windows-latest.o</system-linker-arg>
                <resource-config-file>resource-config-windows.json</resource-config-file>
            </properties>
        </profile>
    </profiles>
</project>
@SaptarshiSarkar12
Copy link
Author

cc @jperedadnr

@SaptarshiSarkar12
Copy link
Author

Can anyone help me to fix this problem?

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

No branches or pull requests

1 participant