Bug 2395 - bindings compilation failure for Python 3.5
bindings compilation failure for Python 3.5
Status: RESOLVED FIXED
Product: ns-3
Classification: Unclassified
Component: python bindings
ns-3.25
All All
: P5 normal
Assigned To: Gustavo J. A. M. Carneiro
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2016-05-03 17:56 UTC by Tom Henderson
Modified: 2016-05-03 21:05 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Henderson 2016-05-03 17:56:48 UTC
ns-3.25 fails to build on an Ubuntu 16.04 (gcc-5.3.1, python 3.5.1) system when Python-3.5 is used.  

To reproduce, unpack the ns-allinone-3.25 release, cd into ns-3.25, and run:

./waf configure

make sure that Python bindings are 'enabled', then run:

./waf build

The error is:

src/fd-net-device/bindings/ns3module.cc:2078:1: error: invalid conversion from ‘cmpfunc {aka void*}’ to ‘PyAsyncMethods*’ [-fpermissive]
 };

(although this can be observed also in other modules such as wimax; it depends on compilation order).   

That part of the ns3module.cc file generated by python-3.5 is:

PyTypeObject PyNs3FdNetDeviceHelper_Type = {
    PyVarObject_HEAD_INIT(NULL, 0)
    (char *) "fd_net_device.FdNetDeviceHelper",            /* tp_name */
    sizeof(PyNs3FdNetDeviceHelper),                  /* tp_basicsize */
    0,                                 /* tp_itemsize */
    /* methods */
    (destructor)_wrap_PyNs3FdNetDeviceHelper__tp_dealloc,        /* tp_dealloc */
    (printfunc)0,                      /* tp_print */
    (getattrfunc)NULL,       /* tp_getattr */
    (setattrfunc)NULL,       /* tp_setattr */
    (cmpfunc)NULL,           /* tp_compare */
    (reprfunc)NULL,             /* tp_repr */
    (PyNumberMethods*)NULL,     /* tp_as_number */


The cmpfunc related to tp_compare is the one the compiler is complaining about.  Note that Python 3.5 documentation states:

  PyAsyncMethods *tp_as_async; /* formerly known as tp_compare (Python 2)
                                    or tp_reserved (Python 3) */

I can confirm that this problem is only with Python 3.5 and not 3.4
Comment 1 Tom Henderson 2016-05-03 17:59:56 UTC
workaround options (choose one of the below):

1) disable python if not needed:

./waf configure --disable-python ...

2) download python and python-dev for python2 version

sudo apt-get install python python-dev

On ubuntu, this will cause python2 to be invoked when the user types 'python'.

3) run a python2 virtualenv (if python3 is still selected by default) or run the waf commands through python2; e.g.:

python2 ./waf configure ...
python2 ./waf build
Comment 2 Gustavo J. A. M. Carneiro 2016-05-03 18:32:02 UTC
I fixed this in pybindgen on github.  The new version string should be '0.17.0.post50+ngec55eb6'.
Comment 3 Tom Henderson 2016-05-03 18:42:10 UTC
(In reply to Gustavo J. A. M. Carneiro from comment #2)
> I fixed this in pybindgen on github.  The new version string should be
> '0.17.0.post50+ngec55eb6'.

Thanks for fast response; I'll test it and update the ns-3 wscript accordingly.
Comment 4 Tom Henderson 2016-05-03 21:05:51 UTC
updated version string in 12097:7f928d5b2c26

I also created ns-3.25 release errata here with instructions on how to workaround: https://www.nsnam.org/wiki/Ns-3.25-errata