Building JOGL on the command line

From JogampWiki
Revision as of 19:40, 10 January 2011 by Wwalker (talk | contribs) (First complete version)
Jump to navigation Jump to search

Overview

To build JOGL on the command line, we'll need to install prerequisites like Ant, pull the code from a repository, and run the Ant build scripts.

Install a JDK

The first thing we need is a Java Development Kit (JDK). JOGL can work with OpenJDK and IcedTea, but here I use Oracle's JDK as an example.

If you've got some kind of Java installed, but you're not sure whether it's a JDK or a Java Runtime Environment (JRE), look inside the directory. If it's got a "jre" subdirectory inside, it's a JDK. A JRE contains only "bin" and "lib" directories.

  • Download the JDK from at http://www.oracle.com/technetwork/java/javase/downloads/index.html.
    • Make sure you get Java SE 6 update 23 or later.
  • Install the JDK wherever you like.
  • Add the JDK bin directory to your path.
    • You must use a JDK bin directory, not a JRE bin directory, because Ant needs javac, which doesn't come in the JRE.
    • On Windows, append ";your JDK\bin" to your Path environment variable.
    • On Linux, append ":your JDK/bin" to your PATH environment variable.
  • Set the JAVA_HOME environment variable to your JDK path.
    • You must use a JDK, not a JRE, because Ant needs lib\tools.jar, which doesn't come in the JRE.
  • Test your JDK by opening a shell and typing "java -version" and "javac -version".

Install Ant

If you don't already have Ant installed, or your version is older than 1.8, you'll need to install a new version of Ant.

  • Download Ant 1.8 or later from http://ant.apache.org/bindownload.cgi.
    • For example, download the file apache-ant-1.8.2-bin.zip and unzip it to your desired installation directory.
  • Set your ANT_HOME environment variable to the new installation directory.
  • Add Ant executables to your path
    • On Windows, append ";your Ant dir\bin" to your Path environment variable.
    • On Linux, append ":your Ant dir/bin" to your PATH environment variable.
  • Test your Ant installation by opening a shell and typing "ant -version".

Unset the classpath

Unset the CLASSPATH environment variable if it exists. Having this set with random JARs on it is one of the main causes of build problems.

  • On Windows, remove it from the list of environment variables in "My Computer > Properties > Advanced > Environment Variables > System Variables".
  • On Linux, remove it from your .cshrc or equivalent shell setup file.

Install Git

The JOGL project uses Git for source code management and collaboration. If you don't already have it, you'll need to install Git 1.7.0 or later.

  • On Windows
  • On Linux
  • Test your Git installation by opening a new shell and typing "git --version".

Install MinGW (Windows only)

For the JOGL build scripts to run on Windows, you'll need Minimalist GNU for Windows (MinGW) so you can use the gcc compiler.

  • Create a "C:\MinGW" directory.
  • Download the installer from http://sourceforge.net/projects/mingw/files/Automated%20MinGW%20Installer/mingw-get/ into the new directory.
    • For example, version mingw-get-0.1-alpha-5 is in a file called mingw-get-0.1-mingw32-alpha-5-bin.zip
  • Extract the installer file.
    • The "bin", "libexec", and "var" directories should be directly inside C:\MinGW.
  • Append ";C:\MinGW\bin" to the end of your Path environment variable.
  • Open new shell and type "mingw-get install gcc".
    • This may take a few minutes to download and install the rest of MinGW.
  • Test your MinGW installation by opening a new shell and typing "gcc --version".

Get the JOGL source code

You'll need to get the source code for two projects, gluegen and jogl. The simple way to get it is by cloning the canonical repository.

  • Open a shell and cd to where you want the code to go
  • Type "git clone git://github.com/sgothel/gluegen.git gluegen"
    • Wait for the code to download. You should see a new "gluegen" directory in your working directory.
  • Type "git clone git://github.com/sgothel/jogl.git jogl"
    • Wait for the code to download. You should see a new "jogl" directory in your working directory.

Build JOGL

You actually have to build gluegen first, then jogl.

  • Build gluegen
    • cd to gluegen/make
    • Type "ant clean"
    • Type "ant"
  • Build jogl
    • cd to jogl/make
    • Type "ant clean"
    • Type "ant"

You'll see lots of ANTLR warnings, these are OK.

Test the JOGL build

To test the build, cd to jogl/make and type "ant junit.run". This will run the full suite of JUnit tests.