Difference between revisions of "BuildingTheFactJniLibrary"

From Protege Wiki
Jump to: navigation, search
(The Java Compile)
(The C++ compile)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
= Handling Problems with FaCT++ not Finding Libraries =
 
= Handling Problems with FaCT++ not Finding Libraries =
  
== The C++ compile ==
 
'''In Progress...'''
 
  
Note that if you do this on a Mac then Xcode 2.2 or greater is recommended in order to get a universal binary.
+
== Building The FaCT++ jni library ==
  
First checkout FaCT++ with the command line call:
+
Because FaCT++ is written in C++, it is a little harder to get it to compile properly across platforms.  In particular, a user may see errors such as
  svn checkout http://factplusplus.googlecode.com/svn/trunk/ factplusplus.
+
Link (dyld) error:
We now need to edit the Makefile.include to use the options associated with the correct version of gcc. First we find the version of gcc with the command line
+
  Symbol not found: _clock$UNIX2003
  gcc -v
+
or a  java.lang.UnsatisfiedLinkError with a message similar to the following
On my linux machine the result was
+
libFaCTPlusPlusJNI.so: /usr/lib/libstdc++.so.6: version `GL IBCXX_3.4.9' not found (required by libFaCTPlusPlusJNI.so)
Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.6/specs
+
This happens because the version of FaCT++ that was compiled into the Protege 4 owl editor is not compatible with the libraries in the users operating system. If this happens on a windows or an OS X machine then send a message to the [mailto:p4-feedback@lists.stanford.edu P4 mailing list] because the developers probably should fix  this situation(If you are not subscribed to this list look at [https://mailman.stanford.edu/mailman/listinfo/p4-feedback this web page].) However on a linux or other operating system this is much more difficult because there are too many different variantsIn this case you will probably have to build you own version of FaCT++Hence we added the following page to make the work a little easier.
  Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-java-awt=gtk --host=i386-redhat-linux
 
Thread model: posix
 
gcc version 3.4.6 20060404 (Red Hat 3.4.6-9)
 
So I modified the Makefile.include so that the GENERAL_DEFINES were
 
  GENERAL_DEFINES = $(GCC_OPT_OPT) $(GCC_34_OPT) $(ALL_DEF)
 
Now much of the building progresses fineBut it seems that building the jnilibrary does not work on most machines.  So here are some machine specific options for how to finish the build.
 
  
=== Linking the JNI Library in os x. ===
 
  
The commands
+
== The C++ compile ==
 
 
cd FaCT++.JNI
 
g++ -dynamiclib -framework JavaVM -I/System/Library/Frameworks/JavaVM.framework/Headers \
 
  obj/FaCTPlusPlus.o ../Kernel/obj/*.o ../Bdd/obj/*.o -o obj/FaCTPlusPlus.jnilib
 
  
compile but don't work at runtime.
+
On Ubuntu I used
 +
<pre>
 +
  export CPLUS_INCLUDE_PATH=${JAVA_HOME}/include:${JAVA_HOME}/include/linux
 +
  sudo apt-get install libxerces-c2-dev
 +
</pre>
  
 
== The Java Compile ==
 
== The Java Compile ==
  
Set the owlapi variable to the location of the owlapi jar file, e.g.
+
There is no build file for the java file so we go back to basic java commands.  Set the owlapi variable to the location of the owlapi jar file, e.g.
 
  owlapi=~/dev/workspaces/protege4/owleditor/plugins/org.semanticweb.owl.owlapi/lib/owlapi-bin.jar
 
  owlapi=~/dev/workspaces/protege4/owleditor/plugins/org.semanticweb.owl.owlapi/lib/owlapi-bin.jar
 
Then the command line
 
Then the command line

Latest revision as of 15:07, December 16, 2009

Handling Problems with FaCT++ not Finding Libraries

Building The FaCT++ jni library

Because FaCT++ is written in C++, it is a little harder to get it to compile properly across platforms. In particular, a user may see errors such as

Link (dyld) error:
Symbol not found: _clock$UNIX2003

or a java.lang.UnsatisfiedLinkError with a message similar to the following

libFaCTPlusPlusJNI.so: /usr/lib/libstdc++.so.6: version `GL IBCXX_3.4.9' not found (required by libFaCTPlusPlusJNI.so)

This happens because the version of FaCT++ that was compiled into the Protege 4 owl editor is not compatible with the libraries in the users operating system. If this happens on a windows or an OS X machine then send a message to the P4 mailing list because the developers probably should fix this situation. (If you are not subscribed to this list look at this web page.) However on a linux or other operating system this is much more difficult because there are too many different variants. In this case you will probably have to build you own version of FaCT++. Hence we added the following page to make the work a little easier.


The C++ compile

On Ubuntu I used

   export CPLUS_INCLUDE_PATH=${JAVA_HOME}/include:${JAVA_HOME}/include/linux
   sudo apt-get install libxerces-c2-dev

The Java Compile

There is no build file for the java file so we go back to basic java commands. Set the owlapi variable to the location of the owlapi jar file, e.g.

owlapi=~/dev/workspaces/protege4/owleditor/plugins/org.semanticweb.owl.owlapi/lib/owlapi-bin.jar

Then the command line

javac -cp $owlapi -d classes -g `find FaCT++.Java -name "*.java"`

works - though there were some compile errors that were easily fixed and I agreed with the compiler. Then

cd classes
jar -cf ../FaCTPlusPlus.jar `find . -name "*.class"`

finishes the job.

Troubleshooting

The xerces C Library Home Page