Compiling for cross platform use

Started by Suds, September 15, 2011, 14:26:27

Previous topic - Next topic

Suds

Hey. I'm new to lwjgl and have been hanging out in the IRC channel.

I'm starting out on a cross platform project with lwjgl. Most importantly, it has to run on Windows and Mac with minimal effort. The project is actually in mid development with XNA and C#, but thanks to foresight and the nature of the code; its almost entirely copy/paste portable with my sprite and cube classes being the only things that need rewriting (that and a project-wide replace "bool" with "boolean" :-p ).

I've made a really, really basic game project for testing purposes in lwjgl at the moment (just a quad that follows the mouse). I just want to learn the steps involved in compiling it for distribution and testing across platforms with eclipse. I just want to make sure I can keep my project working fully cross platform right from the start, so I don't get any surprises later.

Can anyone outline those steps for me please?

EDIT: That would also involve compiling for the mac while using windows, if possible. So I can send the resulting .jar to my _one_ friend with a mac.

kappa

yes, start with the LWJGL Wiki for info on how to get setup with an IDE.

Thereafter see the Basics Tutorial Series found on the wiki (5 parts). It should get you started and get you to the point where you can draw a quad on the screen. Thereafter its mostly just learning OpenGL.

For distribution the LWJGL General FAQ has a section that covers the various options available. Something like the JarSplice should get you started pretty quickly to create crossplatform single jars.

Suds

Thats not quite what I meant. I have prior experience with OpenGL, and already have a quad drawing (turned it into a rotating cube since i made the first post).

I'm asking about the process involved in building the project for multiple platforms or operating systems.

But thanks for the prompt response. :-)

EDIT: Saw your edit. Thanks! :-)

Suds

Quote from: kappa on September 15, 2011, 14:46:20
For distribution the LWJGL General FAQ has a section that covers the various options available. Something like the JarSplice should get you started pretty quickly to create crossplatform single jars.

Okay, turns out I still need a bit of help. I seem to be having most trouble with exporting the JAR to use with JarSplice. I tried to follow this tutorial http://lwjgl.org/forum/index.php?topic=2239.0 and ended up with a build.xml looking like this:

<?xml version="1.0" encoding="UTF-8"?>

<project name="DungeonWars Java" default="Engine" basedir="bin">
<target name="Engine" description="Make the engine">
   <jar jarfile="DungeonWars.jar" basedir=".">
       <manifest>
         <attribute name="Class-Path" value="lwjgl.jar"/>
         <attribute name="Main-Class" value="dungeonwars.game.MainGame"/>
       </manifest>
    </jar>
</target>
</project>


I get the feeling that I'm missing something in that file, but I dont know what. Either way, I end up building a jar file, and when I run it, i get
"Exception in thread "main" java.lang.NoClassDefFoundError: org/lwjgl/LWJGLException"


This seems like a straightforward error; I appear to be missing a reference to the lwjgl libraries somewhere. But where?

kappa

if you're using JarSplice do as follows

1) only export your project from eclipse to a jar (i.e. the project class files and resources such as images, sounds, etc), no need to add any 3 party libraries to it at this point.

2) Start JarSplice, on the jars tab you will add your exported jar, lwjgl.jar and any other external jars your project relies on.

3) On the natives tab add all the lwjgl natives

4) on the class tab add the name of your Main class (complete with any package names).

5) Then just click build to create an executable jar.

Quote from: Suds on September 16, 2011, 09:39:59
"Exception in thread "main" java.lang.NoClassDefFoundError: org/lwjgl/LWJGLException"

The above exception usually means that lwjgl.jar is missing.

Suds

Perfect instructions. Thanks! (Perhaps this could/should be made into a proper wiki tutorial?)

I now have my game prototype working exactly the same on both my windows PC, and my friend's mac. Now I just need to test it on my linux machines. Thanks a lot Kappa!