[OdeJava] Howto getting odejave to run under Mac OS X 10.5 Leopard?

Hi,
today I tried to set-up a java eclipse project for which I wanted to use odejava. In short, I failed in doing so :frowning:
Here are my PC specs:
Mac OS X 10.5 Leopard on a macbook pro with intel dual core, mac java VM 1.5_something, eclipse 3.3, macports for all the handy linux/unix programs the mac shell didn’t offer and gcc4 by apple.

Now the long story:
First I found the pretty outdated files on odejava.dev.java.net in the Documents & files section.
After a quick search, I found a few threads about the libodejava.jnilib version in the CVS section of the said website.

The next step was to download ode-0.9 from ode.org (at that time, I hadn’t found out, that the buildscript would download it by itself …). I unpacked it into /usr/local/src/ and ./configured it, but the make after that failed:
The first problem was, that uint32 was already #defined by an apple .h file, so I edited the (forgot the path)/config.h file and commented out

#define unsigned short uint32

The second problem was, that Leopard already included some openGL stuff, that /usr/X11/lib wanted to include again, which caused a new error

ld: cycle in dylib re-exports with /usr/X11/lib/libGL.dylib

. after finding the following post http://trac.macports.org/projects/macports/ticket/12997 I removed every appearance of /usr/X11/lib from all Makefiles in the ode-0.9 download. Sounds like a solution from someone without bash/make skills … and so it is :slight_smile: But after that ode compiled, and it installed
two files after calling make install: /usr/local/lib/libode.a and /usr/local/lib/libode.dylib

Then I went back to the odejava cvs checkout. I saved the checkout under /usr/local/src, installed dos2unix and automake over macports and tried to execute build-odejava-jni-osx.sh script in odejava/odejave-jni/build.
The first problem was, that the configure script of opende couldn’t identify the type of executable from the gcc compiler. I fixed that by adding


CFLAGS=
CXXFLAGS=

to line 2436 in the configure script generated from autogen.sh, between

ac_config_headers="$ac_config_headers include/ode/config.h"

and

DEPDIR="${am__leading_dot}deps"

I found that two lines by comparing the opende and ode-0.9 configure script, it was the only difference, and the ode script executed, while the opende script did not, so don’t ask my why it did work :slight_smile:
After that, the big surprise, the script downloaded ode again (maybe I should look into such scripts the next time BEFORE I execute them), and tried to compile it, with the same problems I had the last time. That was the moment I stopped, and searched the odejava folder for some precompiled libs. I found the libodejava.jnilib along with other .so files and the dll, and copied it over into my eclipse project. Next I searched for jarfiles, and found the log4j and other jars and copied them over to my project, too. Last but not least I executed the ant buildfile in the odejava subfolder, which built me a handy odejava.jar, which joined the log4j jarfile in my project.

The next step was to add all the jars to the buildpath, and add the dir with the .jnilib and .so files to java.library.path and write some pretty simple main() method:


public static void main(String[] args) 
{
    String libraryVersion = Odejava.getLibraryVersion();
    System.out.println( "Successfully loaded libarary version " + libraryVersion );
}

But it failed to run with the following message:


0    [main] FATAL odejava  - Native code library failed to load. java.lang.UnsatisfiedLinkError: dCCylinderClass_get
Exception in thread "main" java.lang.NoClassDefFoundError
  at org.odejava.Odejava.getLibraryVersion(Odejava.java:140)
  (....)

Without adding the lib folder to java.library.path I got


0    [main] FATAL odejava  - Native code library failed to load. java.lang.UnsatisfiedLinkError: no odejava in java.library.path
Exception in thread "main" java.lang.UnsatisfiedLinkError: ODEJAVA_VERSION_get
  at org.odejava.ode.OdeJNI.ODEJAVA_VERSION_get(Native Method)
  at org.odejava.ode.OdeConstants.<clinit>(OdeConstants.java:12)
  at org.odejava.Odejava.getLibraryVersion(Odejava.java:140)
  (....)

Searching for ‘dCCylinderClass_get’ got me 0 results, so I am stucked now, someone has some help?

Thanks in advance, and sorry for the lengthy post and bad english

Make sure you

  1. use automake 1.9 for ODE up to rev 1322 and automake 1.10 for 1323 and above.
  2. use the branch “with-odejava-jni” of odejava if you use the odejava-jni module (but don’t use the branch in the odejava-jni module itself)

The build script of odejava-jni should work without modification (it is using ODE rev 1295) if you have all required tools installed (tested on OSX 10.4 two weeks ago).

Why do you try to build the natives yourselves, btw? The ones in odejava-jni cvs are up to date.

first in reply to your 1 points:

  1. I have installed automake 1.10
  2. ok, I hasn’t used the branch, but the head
    rev 1323 sounds like SVN to me, but I only found a CVS repos on the https://odejava.dev.java.net/source/browse/odejava/ website.

Yesterday I started a new try, with (hopefully) the right branch, I downloaded the following:
cvs -d :pserver:username@cvs.dev.java.net:/cvs checkout odejava -r with-odejava-jni

Then I followed the odejava/odejava-jni/build/build-odejava-jni-osx.sh script:

sh-3.2# export JAVA_INCLUDE=/System/Library/Frameworks/JavaVM.framework/Home/include
sh-3.2# export DEV_SDK=/Developer/SDKs/MacOSX10.5.sdk/
sh-3.2# cat src/ode.patch|grep (revision|head -1|sed -e ‘s/.(revision (.))/\1/’

996

sh-3.2# svn -q co https://opende.svn.sourceforge.net/svnroot/opende/trunk opende -r 996

Error validating server certificate for 'https://opende.svn.sourceforge.net:443':
 - The certificate is not issued by a trusted authority. Use the
   fingerprint to validate the certificate manually!
Certificate information:
 - Hostname: *.svn.sourceforge.net
 - Valid: from Oct  9 14:15:07 2007 GMT until Dec  8 15:15:07 2008 GMT
 - Issuer: Equifax Secure Certificate Authority, Equifax, US
 - Fingerprint: fb:75:6c:40:58:ae:21:8c:63:dd:1b:7b:6a:7d:bb:8c:74:36:e7:8a
(R)eject, accept (t)emporarily or accept (p)ermanently? t

sh-3.2# cd opende/
sh-3.2# patch -p0 < …/src/ode.patch

patching file include/ode/common.h
patching file include/ode/objects.h
patching file include/ode/odecpp.h
patching file ode/src/error.cpp
patching file ode/src/joint.cpp
patching file ode/src/joint.h

sh-3.2# sh autogen.sh

Please make sure that you use automake 1.8.2 or later
Warnings about underquoted definitions are harmless
Running aclocal
Running autoheader
Running automake
configure.in:5: installing `./config.sub'
configure.in:8: installing `./missing'
configure.in:8: installing `./install-sh'
configure.in:5: installing `./config.guess'
drawstuff/dstest/Makefile.am: installing `./depcomp'
Running autoconf
Now you are ready to run ./configure

sh-3.2# automake --version

automake (GNU automake) 1.10
Written by Tom Tromey <tromey@redhat.com>
       and Alexandre Duret-Lutz <adl@gnu.org>.

Copyright 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

sh-3.2# export CFLAGS="-arch ppc -arch i386 -isysroot $DEV_SDK"
sh-3.2# export CXXFLAGS=$CFLAGS
sh-3.2# ./configure --disable-dependency-tracking --without-tests

checking build system type... i386-apple-darwin9.1.0
checking host system type... i386-apple-darwin9.1.0
checking target system type... i386-apple-darwin9.1.0
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... ./install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking for style of include used by make... GNU
checking for gcc... gcc
checking for C compiler default output file name... a.out
(...)
checking for isnan... yes
checking for isnanf... no
checking for _isnan... no
checking for _isnanf... no
checking for __isnan... yes
checking for __isnanf... yes
checking for working alloca.h... yes
checking for alloca... yes
checking for stdlib.h... (cached) yes
checking for GNU libc compatible malloc... yes
checking for obstacks... no
checking for stdlib.h... (cached) yes
checking for GNU libc compatible realloc... yes
checking sys/select.h usability... yes
checking sys/select.h presence... yes
checking for sys/select.h... yes
checking sys/socket.h usability... yes
checking sys/socket.h presence... yes
checking for sys/socket.h... yes
checking types of arguments for select... int,fd_set *,struct timeval *
checking for vprintf... yes
checking for _doprnt... no
configure: creating ./config.status
config.status: creating Makefile
config.status: creating include/Makefile
config.status: creating include/ode/Makefile
config.status: creating ode/Makefile
config.status: creating ode/src/Makefile
config.status: creating drawstuff/Makefile
config.status: creating drawstuff/src/Makefile
config.status: creating drawstuff/dstest/Makefile
config.status: creating ode/test/Makefile
config.status: creating ode-config
config.status: creating include/ode/config.h
config.status: executing depfiles commands
Configuration:
  Target system type:      i386-apple-darwin9.1.0
  Build  system type:      i386-apple-darwin9.1.0
  Host   system type:      i386-apple-darwin9.1.0
  Use double precision:    no
  Use OPCODE:              yes
  Use gyroscopic term:     yes
  Is this a Pentium:       yes
  Is the CPU x86-64:       no
  Is this a release build: no
  Is this a debug build:   no
  Using SONAME:		  no
  Headers will be installed in /usr/local/include/ode
  Libraries will be installed in /usr/local/lib

After I tried configure the first time today, I got the following error:

(...)
checking for C compiler default output file name... 
configure: error: C compiler cannot create executables
See `config.log' for more details.

It was the same error I got the first time I tried to compile it, previous to my first post. This time I searched a little longer on the net, and I found, that installing XCode 3.0 isn’t enough on Mac OS 10.5 Leopard. The ‘Unix Support Tools’ must be installed, too, and it is only possible to install them AFTER the first Leopard installation, in a second, seperate installation process involving the Leopard DVD. After installing the Unix Support Tools, configure went fine, like shown above.
I Continued the process:
sh-3.2# make

Making all in include
Making all in ode
make  all-am
make[3]: Nothing to be done for `all-am'.
make[2]: Nothing to be done for `all-am'.
Making all in drawstuff
Making all in src
g++ -DHAVE_CONFIG_H -I. -I../../include/ode    -I../../include -I../../include -arch i386 -isysroot /Developer/SDKs/MacOSX10.5.sdk/ -c -o libdrawstuff_a-drawstuff.o `test -f 'drawstuff.cpp' || echo './'`drawstuff.cpp
g++ -DHAVE_CONFIG_H -I. -I../../include/ode    -I../../include -I../../include -arch i386 -isysroot /Developer/SDKs/MacOSX10.5.sdk/ -c -o libdrawstuff_a-osx.o `test -f 'osx.cpp' || echo './'`osx.cpp
/Developer/SDKs/MacOSX10.5.sdk//System/Library/Frameworks/Security.framework/Headers/cssmconfig.h:64: error: conflicting declaration ‘typedef uint32_t uint32’
../../include/ode/config.h:348: error: ‘uint32’ has a previous declaration as ‘typedef short unsigned int uint32’
(...)
make[2]: *** [libdrawstuff_a-osx.o] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all-recursive] Error 1

The same error I had the first time, so I commented out the uint32 define in the config.h file again

sh-3.2# emacs include/ode/config.h
sh-3.2# make

Making all in include
Making all in ode
make  all-am
make[3]: Nothing to be done for `all-am'.
make[2]: Nothing to be done for `all-am'.
Making all in drawstuff
Making all in src
(...)
g++ -DHAVE_CONFIG_H -I. -I../../include/ode    -arch i386 -isysroot /Developer/SDKs/MacOSX10.5.sdk/ -I../../include -I../../include -arch i386 -isysroot /Developer/SDKs/MacOSX10.5.sdk/ -c -o test_basket.o test_basket.cpp
test_basket.cpp: In function ‘void simLoop(int)’:
test_basket.cpp:183: error: ‘__isnanf’ was not declared in this scope
make[2]: *** [test_basket.o] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all-recursive] Error 1

And that’s it, I don’t know how to continue now. Btw changing $DEV_SDK from /Developer/SDKs/MacOSX10.5.sdk/ to /Developer/SDKs/MacOSX10.4u.sdk/ like it is said in the odejava/odejava-jni/build/build-odejava-jni-osx.sh script doesn’t help much, it only results in the compiler error, which states, that the compiler doesn’t produce a executable, because the given SDK doesn’t match the OS.

Is another note, I doesn’t understand the behaviour of the buildscript. It is bundled with a download, which is containing all sourcecode aside from opende, but as one of the first steps, it tries to download odejava again, which causes a new odejava checkout in the checkout some already has downloaded. Therefore I used the buildscript as a guide to compile odejava, and didn’t executed it (besides the fact, that it downloads the head, and you said, I should use the with-odejava-jni branch)

If I made no errors with that, its looks like leopard does behave a little bit different then tiger here, which is bad (for me, and all other leopard users), if nobody in the odejava dev team has leopard on an available machine.

Please try to execute this script (from odejava-jni cvs head) without modification (only set environment variable prior to executing) and without checking out anything yourself. It works on 10.4 and I think it should work 10.5 as well.

And again - why do you even want to build the natives?

I wanted to build it on my own, mainly because if I try to use the built libs in odejava/odejava-jni/bin together with the odejava.jar, which is build from the ant build.xml in odejava/odejava/build.xml I get the following error while calling: System.out.println(Odejava.getLibraryVersion());


0    [main] FATAL odejava  - Native code library failed to load. java.lang.UnsatisfiedLinkError: dCCylinderClass_get
Exception in thread "main" java.lang.NoClassDefFoundError
	at org.odejava.Odejava.getLibraryVersion(Odejava.java:140)
(...)

After I put the build-odejava-jni-osx.sh you pointed to me into a new, empty folder and executed it (after I set the env vars), it started to download (but the script downloads the head of odejava, and not the ‘with-odejava-jni’ branch). Configure went good, and even the uint32 duplicate define error was not there. But again, I got the error with the libGL.dylib:


Making all in CppTestHarness
ld: cycle in dylib re-exports with /usr/X11/lib/libGL.dylib for architecture ppc
collect2: ld returned 1 exit status
ld: cycle in dylib re-exports with /usr/X11/lib/libGL.dylib for architecture i386
collect2: ld returned 1 exit status
lipo: can't open input file: /var/folders/2f/2fUhATI5EgOeAGzxoObLLE+++TI/-Tmp-//cc4RlXTX.out (No such file or directory)
make[2]: *** [ode_unit_test] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all-recursive] Error 1
opende make failed!

To fix (or suppress) it, I removed all ‘-L/-R /usr/X11/lib’ occurrences in all Makefiles in the ode checkout the script made. Starting at ‘Running make for ODE’ I executed the commands from the script by hand, I advanced to the end of the script, and had a compiled libodejava.jnilib.
Then I built the odejava.jar with the odejava/odejava/build.xml file and ant, and copied the resulting jar (and the log4j jar) and the jnilib into my projects lib folder. I included the jar into the classpath, and set -Djava.library.path to the lib dir with the jnilib file.
Now I had the same setup like I had with the prebuild libs from the checkout, but executing System.out.println(Odejava.getLibraryVersion()); this time got me another error:


0    [main] FATAL odejava  - Native code library failed to load. java.lang.UnsatisfiedLinkError: /Users/jarod/diplom_arbeit/ode_opengl/lib/libodejava.jnilib: 
Exception in thread "main" java.lang.UnsatisfiedLinkError: ODEJAVA_VERSION_get
	at org.odejava.ode.OdeJNI.ODEJAVA_VERSION_get(Native Method)
	at org.odejava.ode.OdeConstants.<clinit>(OdeConstants.java:12)
	at org.odejava.Odejava.getLibraryVersion(Odejava.java:140)
(...)

The natives from odejava-jni (head, that’s correct) are for use with the odejava-jni.jar not with the old odejava.jar! That’s why you get the same behavior from the prebuilt natives and the ones built from the script. I’m about to join the branch back into head for the odejava module to use a odejava-jni.jar and prevent more confusion. So stay tuned (or use the branch of odejava/odejava).

The error with the libGL.dylib should be reported to the ODE mailing list, as it seems to hint that ODE does not build on 10.5 without modification.

ok, thx a lot for your help, I will stay tuned and post to the ode maillist about the libGL stuff.

Hehe. I’m curious about the mailing list answering your request. Mine was never answered ;).

Marvin

They answered my question/bugreport

[quote]did you try “./configure --disable-demos”
since then ode runs flawlessly under leopard for me
[/quote]
since the buildscript calls the opende configure script with --disable-demos , there could be some problem with my leopard installation, or the answering person has some problems with his :slight_smile:

Or the CXX_FLAGS with two architectures (-arch stuff) cause the problem? You can remove those lines from the build script and try if that resolves the issue (you just won’t get universal binaries then).

I already tried that, without a result. At the moment the ode people managed it to totally break the code for me, so I hope you get pre-build libs and jars that are running on my mac up into the repository :slight_smile: