Installing java API on Debian

Submitted by carlesg on Mon, 10/17/2016 - 15:45
Forums

I have installed Freeling 4.0 on my Debian 8, using freeling-4.0-jessie-amd64.deb file.
Then, I have tried to install the Java API to access the freeling engine from a java program, so I downloaded the FreeLing-4.0.tar.gz file, I unzipped it, and I have tried to install java API with 'make' (./FreeLing-4.0/APIs/java/Makefile). I have configured the three DIR variables, but the compilation is NOK. The SWIG part does not complain, and it generates a cxx file. But the GCC compilation ends with lots of errors. It seems as if it can not find the freeling objects.

Is there any problem to use the .deb file to install Freeling, and then compile the java API from the tar file ?
I can send you the complete error file, and the cxx file, if needed.
Can you help me to find out where the problem is? Thanks.

Some errors are:

g++ -shared -o libfreeling_javaAPI.so freeling_javaAPI.cxx -lfreeling -L/usr/lib -I/usr/include -I/usr/include/treeler -I/usr/lib/jvm/jdk1.6.0_31/include -I/usr/lib/jvm/jdk1.6.0_31/include/linux -fPIC -std=c++0x
freeling_javaAPI.cxx:329:25: error: ‘argument’ is not a member of ‘freeling’
SWIGINTERN std::vector< freeling::argument >::const_reference std_vector_Sl_freeling_argument_Sg__get(std::vector< freeling::argument > *self,int i){
...
freeling_javaAPI.cxx:350:71: error: ‘predicate’ is not a member of ‘freeling’
SWIGINTERN void std_vector_Sl_freeling_predicate_Sg__set(std::vector< freeling::predicate > *self,int i,std::vector< freeling::predicate >::value_type const &val){
...
freeling_javaAPI.cxx:5713:12: error: ‘tree_preorder_iterator’ is not a member of ‘freeling’
arg1 = *(freeling::tree_preorder_iterator< freeling::node > **)&jarg1;
...

I tried that in ubuntu precise and it worked ok. I'll try on debian later, but there should be no problem

It may be that you have another freeling version installed somewhere and the linker is finding it instead of the 4.0.

Yes. On the same machine we have the freeling version 3.1 installed.
We are now upgrading to 4.0, but we would like to have both installations on different paths, to be used for different applications.
So we took the 3.1 version (installed on /usr/local/...), and have copied the lib, bin, include and data directories to an specific path (/xxx/freeling3.1/). The script that launches our application sets the LD_LIBRARY_PATH and FREELINGSHARE variables to point to those paths before starting java app.

Then, we compiled 4.0 version (on /usr/...), and we wanted to copy the lib, bin, include and data directories to an specific path (/xxx/freeling4.0/). The script that will launch this new application will set the LD_LIBRARY_PATH and FREELINGSHARE variables to point to these paths before starting java app.

But both original installations still stay on original paths (one on /usr/local/lib, and the other on/usr/lib). On runtime, we really don't need the original path installations.

How would we proceed to compile Java API on 4.0?
Should we remove original installation (those on /usr/local/.... and /usr/...?

Thanks

Most likely, the linker is finding 3.1 version in /usr/local before version 4.0 in /usr

You need to make sure that the g++ command that builds the java API will find first the 4.0 version.
See g++ documentation for that.

If you want to have FreeLing installed in custom directories, it is not a good idea to install it in /usr and then move the files.
The best way is building it from source using "./configure --prefix=/my/install/dir". That will install freeling in the requested directory without messing with your system directories. In that way, you'll be able to have a better control of which version is being used at each moment.

You are right.
I have deleted the lib and include files associated to freeling 3.1 (orginally on /urs/local/...), and now the compilation is fine, and I was able to get the javaAPI lib.

Thanks a lot.