How to compile LWJGL?

Started by Andi|xng, May 11, 2005, 23:22:55

Previous topic - Next topic

Andi|xng

Hi,

it really seems to be a funny question for a forum with already more than 5000 messages... We just want to know how to compile the LWJGL. We never did something with Java<->JNI<->C before, so we have no experience with it. Other libraries (e.g. JOAL) have at least a small readme.txt with basic information about builing them from the sources, but LWJGL does really have nothing. The only hyperlink about that topic in the wiki is dead. :(

The concrete problem: org_lwjgl_input_cursor.c needs org_lwjgl_input_cursor.h - but where is the .h? We could not find it anywhere. Perhaps it is created by Java in some way, but as already said, we have no experience with that!

We can not use the precompiled binaries, because we want to add OGG Vorbis support to LWJGL. That means, .ogg files can be loaded and played (even streamed). Our source will be published (BSD license or something similar), so you can also use it if you want to - but please help us. The vorbis things are not really hard, the only problem at the moment is LWJGL...

Thanks!  8)


Andi

Orangy Tang

Quote from: "Andi|xng"We can not use the precompiled binaries, because we want to add OGG Vorbis support to LWJGL. That means, .ogg files can be loaded and played (even streamed).
Er, I dunno how you were planning on doing things, but you don't need to build LWJGL manually just to add ogg support.

Cas' SPGL does ogg playback though LWJGL, which you can find on sourceforge. I havn't looked at it much but I gather most of the heavy lifting is done by JOrbis. And I'm sure I've seen a couple of ogg playback managers on the code snippits bit on javagaming.org.

tomb

You can stream ogg files with  OggInputStream (uses JOrbis).

If you still need to compile the native parts of lwjgl, you defenetly need to read the Java Native Interface tutorial from sun before beginning. You'll find out that the header files are generated from the class files.

But I have to agree, there are little information on how to make everyting compile. Where to get the c compiler and the libraries. There are build scripts that do all the heavy lifting. But it can be challanging the first time you set it up.

princec

The Ant build script has everything in it and "should just work" - at least it seems to for me. For example, we don't commit .h files to CVS - there's an Ant task called "headers" to generate them from the Java. And so on.

Generally speaking... if you've got any specific questions about building, just ask ;) And if you feel like, tweak the Wiki with some answers when you get 'em.

Cas :)

Andi|xng

Thanks for the answers. OK, we'll try it again and will ask if we have more specific questions.

JOrbis is no solution for us, we want to use a fast and stable native library like libvorbis.

Orangy Tang

Why? And is that based on actual, concrete evidence or some random gut instinct? What makes a native lib more stable?

Andi|xng

No, there is no evidence. I do not have the time to test everything, but I can't believe that a native alpha-version Java library like JOrbis (0.0.14!) is as stable and fast as a mature native library like libvorbis. Just look at this comment from JOrbis' readme: "However, in current implementation, the efficiency has not been cared and many CPU resources are required. Much work must be done to solve this problem." I think, I need no more evidence for my decision... But if you can tell me some projects using JOrbis successfully, please tell me about them :)

Concrete problem when compiling LWJGL on WinXP with "ant all":

D:\Test\lwjgl-source-0.96>ant all
Buildfile: build.xml

all:

clean:

-initialize:
[initialiazing lib folder] Created dir: D:\Test\lwjgl-source-0.96\libs
[initialiazing dist folder] Created dir: D:\Test\lwjgl-source-0.96\dist
[initialiazing docs folder] Created dir: D:\Test\lwjgl-source-0.96\doc\javadoc
[initialiazing temp folder] Created dir: D:\Test\lwjgl-source-0.96\temp

compile:
    [lwjgl] Compiling 12 source files to D:\Test\lwjgl-source-0.96\bin
   [openal] Compiling 7 source files to D:\Test\lwjgl-source-0.96\bin
   [opengl] Compiling 150 source files to D:\Test\lwjgl-source-0.96\bin
     [test] Compiling 45 source files to D:\Test\lwjgl-source-0.96\bin
 [examples] Compiling 10 source files to D:\Test\lwjgl-source-0.96\bin
     [util] Compiling 41 source files to D:\Test\lwjgl-source-0.96\bin
     [fmod] Compiling 1 source file to D:\Test\lwjgl-source-0.96\bin
    [devil] Compiling 2 source files to D:\Test\lwjgl-source-0.96\bin

compile:

headers:
    [javah] java.lang.NoClassDefFoundError: com/sun/tools/javah/oldjavah/Main
    [javah] Exception in thread "main"

BUILD FAILED
D:\Test\lwjgl-source-0.96\build.xml:147: The following error occurred while exec
uting this line:
D:\Test\lwjgl-source-0.96\build.xml:575: compilation failed

Total time: 9 seconds


Any ideas? I both tried it with JDK 1.5 and 1.4.2 in the JAVA_HOME-path.
Thanks :)  :)

princec

(All of my games use JOrbis)

Cas :)

Andi|xng

princec, I'm quite surprised, perhaps I underestimated JOrbis 8). Although, this is not the kind of discussion I wanted to start in this thread. The problem is not JOrbis, but compiling LWJGL.

I am sure, as an advanced programmer you had to compile LWJGL for some reasons, too. Did you have any similar problems? Or does anybody know the cause of the problem I described two posts above?

Matzon

I've never seen that error before
can you run javah from the command line ?

Andi|xng

Yes, of course. But this seems not to be a problem with the program javah(.exe), but with the Main-class found in the com.sun.tools.javah.oldjavah-namespace (found in the file <jdkpath>/lib/tools.jar). Any ideas?

Andi|xng

Okay, first partial success. I could avoid the problematic <target name="headers" ...> by generating the .h files "by hand" by using the javah.exe (javah -jni org.lwjgl.opengl.LinuxDisplayPeerInfo, ..., for all files in the "headers"-target).
Let's see how to proceed now...

princec

Looks like your installation is buggered in some clever way - either Ant or the JDK.

Normally I do all my building using a combination of Visual Studio .net, Eclipse 3.1, and the Ant that comes bundled with Eclipse, and I don't have any trouble at all. It "Just Works".

Cas :)

elias

We use Jorbis in Tribal Trouble to play streaming ogg music and we've not had problems with it yet. And the CPU usage is reasonable too.

- elias

Andi|xng

We finally managed it to compile LWJGL :)

The first OggVorbis extension is ready and it is working quite good! Tomorrow I write a small test program, and I will post the link here so anybody can try it if he's interested in it.