Hello Guest

[SOLVED] Building for windows/linux from macos and vicaversa

  • 10 Replies
  • 751 Views
UPDATE: I just found this topic: http://forum.lwjgl.org/index.php?topic=6647.0
I think this is the answer, but let's wait for a confirm.

Hi.

I refactored my app to be able to use java9 modules and I also successfully created a build pipeline with jlink, so now I have a standalone app from my game, which is good. However, I could not figure out, how can I build for windows/linux on osx, or vica-versa.

I handle dependencies with maven this way:
Code: [Select]
...
<dependencies>
...
<dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl</artifactId>
            <version>${lwjgl.version}</version>
        </dependency>
        <dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl-glfw</artifactId>
            <version>${lwjgl.version}</version>
        </dependency>
        <dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl-nanovg</artifactId>
            <version>${lwjgl.version}</version>
        </dependency>
        <dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl-opengl</artifactId>
            <version>${lwjgl.version}</version>
        </dependency>
        <dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl-stb</artifactId>
            <version>${lwjgl.version}</version>
        </dependency>
        <dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl</artifactId>
            <version>${lwjgl.version}</version>
            <classifier>${lwjgl.natives}</classifier>
        </dependency>
        <dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl-glfw</artifactId>
            <version>${lwjgl.version}</version>
            <classifier>${lwjgl.natives}</classifier>
        </dependency>
        <dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl-nanovg</artifactId>
            <version>${lwjgl.version}</version>
            <classifier>${lwjgl.natives}</classifier>
        </dependency>
        <dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl-opengl</artifactId>
            <version>${lwjgl.version}</version>
            <classifier>${lwjgl.natives}</classifier>
        </dependency>
        <dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl-stb</artifactId>
            <version>${lwjgl.version}</version>
            <classifier>${lwjgl.natives}</classifier>
        </dependency>
        <dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl-openal</artifactId>
            <version>${lwjgl.version}</version>
            <classifier>${lwjgl.natives}</classifier>
        </dependency>
        <dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl-assimp</artifactId>
            <version>${lwjgl.version}</version>
        </dependency>
        <dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl-assimp</artifactId>
            <version>${lwjgl.version}</version>
            <classifier>${lwjgl.natives}</classifier>
        </dependency>
....
</dependencies>

<profiles>
        <profile>
            <id>lwjgl-natives-linux</id>
            <activation>
                <os>
                    <family>unix</family>
                </os>
            </activation>
            <properties>
                <lwjgl.natives>natives-linux</lwjgl.natives>
            </properties>
        </profile>
        <profile>
            <id>lwjgl-natives-macos</id>
            <activation>
                <os>
                    <family>mac</family>
                </os>
            </activation>
            <properties>
                <lwjgl.natives>natives-macos</lwjgl.natives>
            </properties>
        </profile>
        <profile>
            <id>lwjgl-natives-windows</id>
            <activation>
                <os>
                    <family>windows</family>
                </os>
            </activation>
            <properties>
                <lwjgl.natives>natives-windows</lwjgl.natives>
            </properties>
        </profile>
    </profiles>

No matter what I turn on/off in Intellij Idea at the profiles tab, it always builds packages the same way. See the attached image.
« Last Edit: August 22, 2018, 05:37:42 by mudlee »

*

Offline KaiHH

  • ***
  • 150
Re: Building for windows/linux from macos and vicaversa
« Reply #1 on: August 21, 2018, 19:10:06 »
It should work when you activate the profile using
Code: [Select]
-P by using
Code: [Select]
mvn -Plwjgl-natives-linux <lifecycle-phase> or
Code: [Select]
mvn -Plwjgl-natives-windows <lifecycle-phase>.
This project ( https://github.com/LWJGL/lwjgl3-demos/blob/master/pom.xml ) uses the same os profile activation and the natives (i.e. the active profile) can be overwritten using the -P mvn switch.

Re: Building for windows/linux from macos and vicaversa
« Reply #2 on: August 22, 2018, 05:37:25 »
It worked, thx!

Re: [SOLVED] Building for windows/linux from macos and vicaversa
« Reply #3 on: October 15, 2018, 17:55:27 »
Didn't want to open a new topic, I got this on windows:
Code: [Select]
[ERROR] Failed to execute goal on project engine: Could not resolve dependencies for project xy:jar:1.0-SNAPSHOT: Could not find artifact org.lwjgl:lwjgl-vulkan:jar:natives-windows:3.2.1-20181014.235349-6 in sonatype-snapshots (https://oss.sonatype.org/content/repositories/snapshots) -> [Help 1]

Command was:
Code: [Select]
mvn -Plwjgl-natives-windows compile
Tried to run on windows and on osx, same error. Compilation for linux and macos works fine.

OK, one more:
Code: [Select]
java.lang.IllegalAccessError: class org.lwjgl.vulkan.VkApplicationInfo (in module org.lwjgl.vulkan) cannot access class sun.misc.Unsafe (in module jdk.unsupported) because module org.lwjgl.vulkan does not read module jdk.unsupported
« Last Edit: October 15, 2018, 18:28:05 by mudlee »

*

Offline spasi

  • *****
  • 2044
    • WebHotelier
Re: [SOLVED] Building for windows/linux from macos and vicaversa
« Reply #4 on: October 15, 2018, 18:55:40 »
First error: the Vulkan bindings do not have a natives artifact.

Second error: This is a problem with the latest 3.2.1 snapshot, I'll try to find a solution soon.

Re: [SOLVED] Building for windows/linux from macos and vicaversa
« Reply #5 on: October 15, 2018, 19:04:22 »
Thanks!

Regarding to the first error: after mvn clean, it happened for all platforms, and then I added the required natives and then the I got the second. Sometimes maven and/or intellij do really weird caches...

*

Offline spasi

  • *****
  • 2044
    • WebHotelier
Re: [SOLVED] Building for windows/linux from macos and vicaversa
« Reply #6 on: October 15, 2018, 20:21:17 »
The second error should be fixed in 3.2.1 snapshot 6.

Re: [SOLVED] Building for windows/linux from macos and vicaversa
« Reply #7 on: October 16, 2018, 05:40:27 »
The module visibility error gone, thx. However I have the same problem now with the natives:

Code: [Select]
[ERROR] Failed to execute goal on project engine: Could not resolve dependencies for project xy:jar:1.0-SNAPSHOT: Could not find artifact org.lwjgl:lwjgl-vulkan:jar:natives-windows:3.2.1-SNAPSHOT in sonatype-snapshots (https://oss.sonatype.org/content/repositories/snapshots) -> [Help 1]
OSX/Linux works fine.

*

Offline spasi

  • *****
  • 2044
    • WebHotelier
Re: [SOLVED] Building for windows/linux from macos and vicaversa
« Reply #8 on: October 16, 2018, 06:56:07 »
As I said above, there is no natives artifact for Vulkan on Windows/Linux. It's only necessary on macOS for the MoltenVK shared library.

Re: [SOLVED] Building for windows/linux from macos and vicaversa
« Reply #9 on: October 16, 2018, 09:01:39 »
Ah, my bad, sorry!

A question tough. Would it be a good way if I ask the user during the installation process to install vulkan too? As on osx it will be automatic with moltenvk, on win/linux I have to rely on the os's sdk, right?
« Last Edit: October 16, 2018, 09:13:40 by mudlee »

*

Offline spasi

  • *****
  • 2044
    • WebHotelier
Re: [SOLVED] Building for windows/linux from macos and vicaversa
« Reply #10 on: October 16, 2018, 09:43:13 »
You do not need the Vulkan SDK to use Vulkan. On Windows & Linux, it's enough to have a GPU driver with Vulkan support installed. On macOS, MoltenVK simply requires an OS version that supports Metal (i.e. macOS 10.11 or higher).