gluonhq / gluon-samples

Gluon sample projects
298 stars 166 forks source link

SharedLib example for Windows #175

Closed ennerf closed 11 months ago

ennerf commented 11 months ago

This PR adds an example for compiling against the shared library generated on Windows.

Setup substrate snapshot

Install substrate PR 1235 to the local maven repo: gradlew publishToMavenLocal

and modify the pom.xml:

<plugin>
    <groupId>com.gluonhq</groupId>
    <artifactId>gluonfx-maven-plugin</artifactId>
    <version>${gluonfx.maven.plugin.version}</version>
    <configuration>
        <target>${gluonfx.target}</target>
    </configuration>

    <!-- Use the snapshot build of substrate -->
    <dependencies>
        <dependency>
            <groupId>com.gluonhq</groupId>
            <artifactId>substrate</artifactId>
            <version>0.0.61-SNAPSHOT</version>
        </dependency>
    </dependencies>

</plugin>

Build on Windows

mvn gluonfx:sharedlib
run.bat

The output should be:

**********************************************************************
** Visual Studio 2022 Developer Command Prompt v17.6.3
** Copyright (c) 2022 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'

E:\gluon\gluon-samples\HelloSharedLib>run
Microsoft (R) C/C++ Optimizing Compiler Version 19.36.32534 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

example.cpp
Microsoft (R) Incremental Linker Version 14.36.32534.0
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:example.exe
target\gluonfx\x86_64-windows\HelloSharedLib.lib
/out:target\gluonfx\x86_64-windows\example.exe
example.obj
Sum: 3
Diff: -1
Text: Hello from Java