Compiling Python API on Ubuntu 16

Submitted by ulrike.henny on Wed, 11/15/2017 - 11:12
Forums

Hello,
I tried to compile the Python API on Ubuntu 16. The freeling.py is created, but it does not work correctly and I get many error messages when compiling the API. I have the following:

Freeling: 4.0 (stable version)
Linux: Ubuntu 16.04.4
gcc: version 5.4.0 20160609
Python: 3.5.2
SWIG: 3.0.8

I changed the paths in the MAKE file like this:
FREELINGDIR = /usr
PYTHONVER = python3.5
PYTHONDIR = /usr/include/$(PYTHONVER)

The freeling so file is in /usr/lib.
This is the beginning of the error messages that I get (there are many more):

g++ -shared -o _freeling.so freeling_pythonAPI.cxx -lfreeling -I/usr/include -L/usr/lib -I/usr/include/python3.5 -fPIC -std=gnu++0x
freeling_pythonAPI.cxx:5149:33: error: ‘alternative’ is not a member of ‘freeling’
template <> struct traits< freeling::alternative > {
^
freeling_pythonAPI.cxx:5149:33: error: ‘alternative’ is not a member of ‘freeling’
freeling_pythonAPI.cxx:5149:55: error: template argument 1 is invalid
template <> struct traits< freeling::alternative > {
^
freeling_pythonAPI.cxx:5157:40: error: ‘alternative’ is not a member of ‘freeling’
template <> struct traits > > {
^
freeling_pythonAPI.cxx:5157:40: error: ‘alternative’ is not a member of ‘freeling’
freeling_pythonAPI.cxx:5157:79: error: ‘alternative’ is not a member of ‘freeling’
template <> struct traits > > {
^
freeling_pythonAPI.cxx:5157:79: error: ‘alternative’ is not a member of ‘freeling’
freeling_pythonAPI.cxx:5157:101: error: template argument 1 is invalid
template <> struct traits > > {
^
freeling_pythonAPI.cxx:5157:103: error: template argument 1 is invalid
template <> struct traits > > {
^
freeling_pythonAPI.cxx:5157:103: error: template argument 2 is invalid
freeling_pythonAPI.cxx:5157:105: error: template argument 1 is invalid
template <> struct traits > > {
^
freeling_pythonAPI.cxx:5165:91: error: ‘alternative’ is not a member of ‘freeling’
SWIGINTERN swig::SwigPyIterator *std_list_Sl_freeling_alternative_Sg__iterator(std::list< freeling::alternative > *self,PyObject **PYTHON_SELF){
^
freeling_pythonAPI.cxx:5165:91: error: ‘alternative’ is not a member of ‘freeling’
freeling_pythonAPI.cxx:5165:113: error: template argument 1 is invalid
SWIGINTERN swig::SwigPyIterator *std_list_Sl_freeling_alternative_Sg__iterator(std::list< freeling::alternative > *self,PyObject **PYTHON_SELF){
^
freeling_pythonAPI.cxx:5165:113: error: template argument 2 is invalid
freeling_pythonAPI.cxx: In function ‘swig::SwigPyIterator* std_list_Sl_freeling_alternative_Sg__iterator(int*, PyObject**)’:
freeling_pythonAPI.cxx:5166:47: error: request for member ‘begin’ in ‘* self’, which is of non-class type ‘int’
return swig::make_output_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF);

Any help will be much appreciated!
Ulrike

You are using and API definition that does not match the library version.

If you installed FreeLing 4.0 from a .deb package, you need to use the API definitions in FreeLing-4.0 source tarball.
  If you use the API from master, it will not work.

ulrike.henny

Thu, 11/16/2017 - 17:55

Hello,
now it worked without any error messages. Thank you very much!
Ulrike