New to cgal-bindings - can not run java examples

9 views
Skip to first unread message

Stuart Rowland

unread,
Dec 15, 2019, 7:53:20 PM12/15/19
to CGAL Bindings discuss
I need the capabilities of CGAL for my java program. I am trying to run the java examples in order to get experience with CGAL binding.

I successfully built cgal-swig-bindings using cmake.  I then copied the examples directory into my build directory and in the examples/java directory ran the test.sh file.  Nothing compiled. Looking at test.sh, I realized that both the javac and java commands needed the
'-cp ../../build-java:.'
parameter.  Now everything builds, but nothing runs.  Java can not find the libraries. Java needed the
'-Djava.library.path=../../lib'
parameter.  It still can not find the libraries.  The code is looking for a library named libCGAL_Kernel.so, but cmake named the library libCGAL_Kernel_cpp.so.  All the libraries had _cpp in their name, so I renamed them all.  Now java can find the libraries, but the examples still do not run.  I get errors like:

Exception in thread "main" java.lang.UnsatisfiedLinkError: CGAL.Kernel.CGAL_KernelJNI.new_Point_3__SWIG_2(DDD)J
    at CGAL.Kernel.CGAL_KernelJNI.new_Point_3__SWIG_2(Native Method)
    at CGAL.Kernel.Point_3.<init>(Point_3.java:47)
    at simple_triangulation_3.main(simple_triangulation_3.java:16)

Running nm on libCGAL_Kernel.so, I do not see any symbol even similar to that in the error message.

I am running Fedora 26 with  gcc (GCC) 7.3.1, java version "1.8.0_121", cmake version 3.11.0, SWIG Version 3.0.12.  I installed CGAL using dnf (aka yum).  The libraries are labelled version 11.0.0.

I do not understand what I am doing wrong.  Any help will be greatly appreciated.  Thank you.


Sebastien Loriot (GeometryFactory)

unread,
Dec 19, 2019, 1:34:36 AM12/19/19
to cgal-bindi...@googlegroups.com
libCGAL_Kernel.so and libCGAL_Kernel_cpp.so are two different libraries
and you should not have renamed it.

libCGAL_Kernel.so should be in $BUILD_DIR/build-java/lib
That path should be added to the ld library path variable
(maybe there is an option on java command line).

Sebastien.
> --
> You received this message because you are subscribed to the Google
> Groups "CGAL Bindings discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to cgal-bindings-di...@googlegroups.com
> <mailto:cgal-bindings-di...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/cgal-bindings-discuss/8b809226-c7c6-4303-880c-e6df4f8a8769%40googlegroups.com
> <https://groups.google.com/d/msgid/cgal-bindings-discuss/8b809226-c7c6-4303-880c-e6df4f8a8769%40googlegroups.com?utm_medium=email&utm_source=footer>.

Sebastien Loriot (GeometryFactory)

unread,
Dec 19, 2019, 1:37:27 AM12/19/19
to cgal-bindi...@googlegroups.com
Actually, libCGALKernel.so should be built by the target CGAL_Kernel.

Sebastien.

Stuart Rowland

unread,
Dec 19, 2019, 6:13:50 PM12/19/19
to CGAL Bindings discuss
Thank you.  I did not notice that directory.  A corrected test.sh follows.

rm -f error.txt

for i in `egrep -l "public\s+static\s+void\s+main" *.java`; do
  name=`echo $i | sed 's/\.java//'`;
  echo ==================Running  $name ==================
  if javac -cp ../../build-java:. $i; then
    echo $i compiled >> error.txt
    if java -cp ../../build-java:. $name; then
      echo $name run OK >> error.txt
    else
      echo $name run Error >> error.txt
    fi
  else
    echo $i compilation error >> error.txt
  fi
done

where LD_LIBRARY_PATH includes the directory containing  libCGAL_Kernel.so.
Reply all
Reply to author
Forward
0 new messages