adaptagrams
adaptagrams copied to clipboard
building swig python interface fails
Hi, I'm trying to build the python library with swig but it fails.
What I've done: build cola with autogen.sh
. It passes all the tests. then sudo make install
.
to build the python library I did:
swig -c++ -python adaptagrams.i
and
python swig-python-setup.py install
I have python3.6. It then fails with:
running install
running build
running build_py
copying adaptagrams.py -> build/lib.linux-x86_64-3.6
running build_ext
building '_adaptagrams' extension
gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -fPIC -I. -I/usr/include/python3.6m -c adaptagrams_wrap.cxx -o build/temp.linux-x86_64-3.6/adaptagrams_wrap.o -DUSE_ASSERT_EXCEPTIONS -DSWIG_PYTHON_SILENT_MEMLEAK
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
In file included from adaptagrams_wrap.cxx:3734:
./libtopology/topology_graph.h:242:22: warning: ‘template<class _Operation> class std::binder1st’ is deprecated [-Wdeprecated-declarations]
typedef std::binder1st<
^~~~~~~~~
In file included from /usr/include/c++/8.1.1/bits/stl_function.h:1368,
from /usr/include/c++/8.1.1/string:48,
from adaptagrams_wrap.cxx:3032:
/usr/include/c++/8.1.1/backward/binders.h:108:11: note: declared here
class binder1st
^~~~~~~~~
adaptagrams_wrap.cxx: In function ‘PyObject* _wrap_new_CriticalFailure__SWIG_0(PyObject*, PyObject*)’:
adaptagrams_wrap.cxx:44354:9: error: ‘CriticalFailure’ is not a member of ‘vpsc’
vpsc::CriticalFailure *result = 0 ;
^~~~~~~~~~~~~~~
adaptagrams_wrap.cxx:44354:26: error: ‘result’ was not declared in this scope
vpsc::CriticalFailure *result = 0 ;
^~~~~~
adaptagrams_wrap.cxx:44354:26: note: suggested alternative: ‘res4’
vpsc::CriticalFailure *result = 0 ;
^~~~~~
res4
adaptagrams_wrap.cxx:44377:19: error: ‘CriticalFailure’ is not a member of ‘vpsc’
result = (vpsc::CriticalFailure *)new vpsc::CriticalFailure((char const *)arg1,(char const *)arg2,arg3,(char const *)arg4);
^~~~~~~~~~~~~~~
adaptagrams_wrap.cxx:44377:36: error: expected primary-expression before ‘)’ token
result = (vpsc::CriticalFailure *)new vpsc::CriticalFailure((char const *)arg1,(char const *)arg2,arg3,(char const *)arg4);
^
adaptagrams_wrap.cxx: In function ‘PyObject* _wrap_new_CriticalFailure__SWIG_1(PyObject*, PyObject*)’:
adaptagrams_wrap.cxx:44407:9: error: ‘CriticalFailure’ is not a member of ‘vpsc’
vpsc::CriticalFailure *result = 0 ;
^~~~~~~~~~~~~~~
adaptagrams_wrap.cxx:44407:26: error: ‘result’ was not declared in this scope
vpsc::CriticalFailure *result = 0 ;
^~~~~~
adaptagrams_wrap.cxx:44407:26: note: suggested alternative: ‘res2’
vpsc::CriticalFailure *result = 0 ;
^~~~~~
res2
adaptagrams_wrap.cxx:44425:19: error: ‘CriticalFailure’ is not a member of ‘vpsc’
result = (vpsc::CriticalFailure *)new vpsc::CriticalFailure((char const *)arg1,(char const *)arg2,arg3);
^~~~~~~~~~~~~~~
adaptagrams_wrap.cxx:44425:36: error: expected primary-expression before ‘)’ token
result = (vpsc::CriticalFailure *)new vpsc::CriticalFailure((char const *)arg1,(char const *)arg2,arg3);
^
adaptagrams_wrap.cxx: In function ‘PyObject* _wrap_CriticalFailure_what(PyObject*, PyObject*)’:
adaptagrams_wrap.cxx:44501:9: error: ‘CriticalFailure’ is not a member of ‘vpsc’
vpsc::CriticalFailure *arg1 = (vpsc::CriticalFailure *) 0 ;
^~~~~~~~~~~~~~~
adaptagrams_wrap.cxx:44501:26: error: ‘arg1’ was not declared in this scope
vpsc::CriticalFailure *arg1 = (vpsc::CriticalFailure *) 0 ;
^~~~
adaptagrams_wrap.cxx:44501:26: note: suggested alternative: ‘args’
vpsc::CriticalFailure *arg1 = (vpsc::CriticalFailure *) 0 ;
^~~~
args
adaptagrams_wrap.cxx:44501:40: error: ‘CriticalFailure’ is not a member of ‘vpsc’
vpsc::CriticalFailure *arg1 = (vpsc::CriticalFailure *) 0 ;
^~~~~~~~~~~~~~~
adaptagrams_wrap.cxx:44501:57: error: expected primary-expression before ‘)’ token
vpsc::CriticalFailure *arg1 = (vpsc::CriticalFailure *) 0 ;
^
adaptagrams_wrap.cxx:44512:34: error: ‘CriticalFailure’ in namespace ‘vpsc’ does not name a type
arg1 = reinterpret_cast< vpsc::CriticalFailure * >(argp1);
^~~~~~~~~~~~~~~
adaptagrams_wrap.cxx:44512:50: error: expected ‘>’ before ‘*’ token
arg1 = reinterpret_cast< vpsc::CriticalFailure * >(argp1);
^
adaptagrams_wrap.cxx:44512:50: error: expected ‘(’ before ‘*’ token
arg1 = reinterpret_cast< vpsc::CriticalFailure * >(argp1);
^
(
adaptagrams_wrap.cxx:44512:52: error: expected primary-expression before ‘>’ token
arg1 = reinterpret_cast< vpsc::CriticalFailure * >(argp1);
^
adaptagrams_wrap.cxx:44512:60: error: expected ‘)’ before ‘;’ token
arg1 = reinterpret_cast< vpsc::CriticalFailure * >(argp1);
^
)
adaptagrams_wrap.cxx:44513:20: error: ‘CriticalFailure’ is not a member of ‘vpsc’
result = ((vpsc::CriticalFailure const *)arg1)->what();
^~~~~~~~~~~~~~~
adaptagrams_wrap.cxx:44513:35: error: expected ‘)’ before ‘const’
result = ((vpsc::CriticalFailure const *)arg1)->what();
~ ^~~~~~
)
adaptagrams_wrap.cxx:44513:57: error: expected ‘)’ before ‘;’ token
result = ((vpsc::CriticalFailure const *)arg1)->what();
~ ^
)
adaptagrams_wrap.cxx: In function ‘PyObject* _wrap_delete_CriticalFailure(PyObject*, PyObject*)’:
adaptagrams_wrap.cxx:44523:9: error: ‘CriticalFailure’ is not a member of ‘vpsc’
vpsc::CriticalFailure *arg1 = (vpsc::CriticalFailure *) 0 ;
^~~~~~~~~~~~~~~
adaptagrams_wrap.cxx:44523:26: error: ‘arg1’ was not declared in this scope
vpsc::CriticalFailure *arg1 = (vpsc::CriticalFailure *) 0 ;
^~~~
adaptagrams_wrap.cxx:44523:26: note: suggested alternative: ‘args’
vpsc::CriticalFailure *arg1 = (vpsc::CriticalFailure *) 0 ;
^~~~
args
adaptagrams_wrap.cxx:44523:40: error: ‘CriticalFailure’ is not a member of ‘vpsc’
vpsc::CriticalFailure *arg1 = (vpsc::CriticalFailure *) 0 ;
^~~~~~~~~~~~~~~
adaptagrams_wrap.cxx:44523:57: error: expected primary-expression before ‘)’ token
vpsc::CriticalFailure *arg1 = (vpsc::CriticalFailure *) 0 ;
^
adaptagrams_wrap.cxx:44533:34: error: ‘CriticalFailure’ in namespace ‘vpsc’ does not name a type
arg1 = reinterpret_cast< vpsc::CriticalFailure * >(argp1);
^~~~~~~~~~~~~~~
adaptagrams_wrap.cxx:44533:50: error: expected ‘>’ before ‘*’ token
arg1 = reinterpret_cast< vpsc::CriticalFailure * >(argp1);
^
adaptagrams_wrap.cxx:44533:50: error: expected ‘(’ before ‘*’ token
arg1 = reinterpret_cast< vpsc::CriticalFailure * >(argp1);
^
(
adaptagrams_wrap.cxx:44533:52: error: expected primary-expression before ‘>’ token
arg1 = reinterpret_cast< vpsc::CriticalFailure * >(argp1);
^
adaptagrams_wrap.cxx:44533:60: error: expected ‘)’ before ‘;’ token
arg1 = reinterpret_cast< vpsc::CriticalFailure * >(argp1);
^
)
adaptagrams_wrap.cxx:44534:10: error: type ‘<type error>’ argument given to ‘delete’, expected pointer
delete arg1;
^~~~
adaptagrams_wrap.cxx: In instantiation of ‘static Type swig::traits_as<Type, swig::pointer_category>::as(PyObject*, bool) [with Type = std::pair<unsigned int, unsigned int>; PyObject = _object]’:
adaptagrams_wrap.cxx:4506:64: required from ‘Type swig::as(PyObject*, bool) [with Type = std::pair<unsigned int, unsigned int>; PyObject = _object]’
adaptagrams_wrap.cxx:5073:20: required from ‘swig::SwigPySequence_Ref<T>::operator T() const [with T = std::pair<unsigned int, unsigned int>]’
adaptagrams_wrap.cxx:5527:30: required from ‘void swig::assign(const SwigPySeq&, Seq*) [with SwigPySeq = swig::SwigPySequence_Cont<std::pair<unsigned int, unsigned int> >; Seq = std::vector<std::pair<unsigned int, unsigned int> >]’
adaptagrams_wrap.cxx:5549:12: required from ‘static int swig::traits_asptr_stdseq<Seq, T>::asptr(PyObject*, swig::traits_asptr_stdseq<Seq, T>::sequence**) [with Seq = std::vector<std::pair<unsigned int, unsigned int> >; T = std::pair<unsigned int, unsigned int>; PyObject = _object; swig::traits_asptr_stdseq<Seq, T>::sequence = std::vector<std::pair<unsigned int, unsigned int> >]’
adaptagrams_wrap.cxx:5610:52: required from ‘static int swig::traits_asptr<std::vector<T> >::asptr(PyObject*, std::vector<T>**) [with T = std::pair<unsigned int, unsigned int>; PyObject = _object]’
adaptagrams_wrap.cxx:4398:37: required from ‘int swig::asptr(PyObject*, Type**) [with Type = std::vector<std::pair<unsigned int, unsigned int> >; PyObject = _object]’
adaptagrams_wrap.cxx:16926:34: required from here
adaptagrams_wrap.cxx:4481:8: warning: ‘void* memset(void*, int, size_t)’ clearing an object of type ‘struct std::pair<unsigned int, unsigned int>’ with no trivial copy-assignment; use assignment instead [-Wclass-memaccess]
memset(v_def,0,sizeof(Type));
~~~~~~^~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/8.1.1/bits/stl_algobase.h:64,
from /usr/include/c++/8.1.1/bits/char_traits.h:39,
from /usr/include/c++/8.1.1/string:40,
from adaptagrams_wrap.cxx:3032:
/usr/include/c++/8.1.1/bits/stl_pair.h:198:12: note: ‘struct std::pair<unsigned int, unsigned int>’ declared here
struct pair
^~~~
adaptagrams_wrap.cxx: In instantiation of ‘static Type swig::traits_as<Type, swig::pointer_category>::as(PyObject*, bool) [with Type = cola::Lock; PyObject = _object]’:
adaptagrams_wrap.cxx:4506:64: required from ‘Type swig::as(PyObject*, bool) [with Type = cola::Lock; PyObject = _object]’
adaptagrams_wrap.cxx:5073:20: required from ‘swig::SwigPySequence_Ref<T>::operator T() const [with T = cola::Lock]’
adaptagrams_wrap.cxx:5527:30: required from ‘void swig::assign(const SwigPySeq&, Seq*) [with SwigPySeq = swig::SwigPySequence_Cont<cola::Lock>; Seq = std::vector<cola::Lock>]’
adaptagrams_wrap.cxx:5549:12: required from ‘static int swig::traits_asptr_stdseq<Seq, T>::asptr(PyObject*, swig::traits_asptr_stdseq<Seq, T>::sequence**) [with Seq = std::vector<cola::Lock>; T = cola::Lock; PyObject = _object; swig::traits_asptr_stdseq<Seq, T>::sequence = std::vector<cola::Lock>]’
adaptagrams_wrap.cxx:5610:52: required from ‘static int swig::traits_asptr<std::vector<T> >::asptr(PyObject*, std::vector<T>**) [with T = cola::Lock; PyObject = _object]’
adaptagrams_wrap.cxx:4398:37: required from ‘int swig::asptr(PyObject*, Type**) [with Type = std::vector<cola::Lock>; PyObject = _object]’
adaptagrams_wrap.cxx:22668:34: required from here
adaptagrams_wrap.cxx:4481:8: warning: ‘void* memset(void*, int, size_t)’ clearing an object of non-trivial type ‘class cola::Lock’; use assignment or value-initialization instead [-Wclass-memaccess]
memset(v_def,0,sizeof(Type));
~~~~~~^~~~~~~~~~~~~~~~~~~~~~
In file included from adaptagrams_wrap.cxx:3729:
./libcola/cola.h:75:7: note: ‘class cola::Lock’ declared here
class Lock {
^~~~
adaptagrams_wrap.cxx: In instantiation of ‘static Type swig::traits_as<Type, swig::pointer_category>::as(PyObject*, bool) [with Type = cola::Resize; PyObject = _object]’:
adaptagrams_wrap.cxx:4506:64: required from ‘Type swig::as(PyObject*, bool) [with Type = cola::Resize; PyObject = _object]’
adaptagrams_wrap.cxx:5073:20: required from ‘swig::SwigPySequence_Ref<T>::operator T() const [with T = cola::Resize]’
adaptagrams_wrap.cxx:5527:30: required from ‘void swig::assign(const SwigPySeq&, Seq*) [with SwigPySeq = swig::SwigPySequence_Cont<cola::Resize>; Seq = std::vector<cola::Resize>]’
adaptagrams_wrap.cxx:5549:12: required from ‘static int swig::traits_asptr_stdseq<Seq, T>::asptr(PyObject*, swig::traits_asptr_stdseq<Seq, T>::sequence**) [with Seq = std::vector<cola::Resize>; T = cola::Resize; PyObject = _object; swig::traits_asptr_stdseq<Seq, T>::sequence = std::vector<cola::Resize>]’
adaptagrams_wrap.cxx:5610:52: required from ‘static int swig::traits_asptr<std::vector<T> >::asptr(PyObject*, std::vector<T>**) [with T = cola::Resize; PyObject = _object]’
adaptagrams_wrap.cxx:4398:37: required from ‘int swig::asptr(PyObject*, Type**) [with Type = std::vector<cola::Resize>; PyObject = _object]’
adaptagrams_wrap.cxx:24584:34: required from here
adaptagrams_wrap.cxx:4481:8: warning: ‘void* memset(void*, int, size_t)’ clearing an object of non-trivial type ‘class cola::Resize’; use assignment or value-initialization instead [-Wclass-memaccess]
memset(v_def,0,sizeof(Type));
~~~~~~^~~~~~~~~~~~~~~~~~~~~~
In file included from adaptagrams_wrap.cxx:3729:
./libcola/cola.h:104:7: note: ‘class cola::Resize’ declared here
class Resize {
^~~~~~
adaptagrams_wrap.cxx: In instantiation of ‘static Type swig::traits_as<Type, swig::pointer_category>::as(PyObject*, bool) [with Type = Avoid::Point; PyObject = _object]’:
adaptagrams_wrap.cxx:4506:64: required from ‘Type swig::as(PyObject*, bool) [with Type = Avoid::Point; PyObject = _object]’
adaptagrams_wrap.cxx:5073:20: required from ‘swig::SwigPySequence_Ref<T>::operator T() const [with T = Avoid::Point]’
adaptagrams_wrap.cxx:5527:30: required from ‘void swig::assign(const SwigPySeq&, Seq*) [with SwigPySeq = swig::SwigPySequence_Cont<Avoid::Point>; Seq = std::vector<Avoid::Point>]’
adaptagrams_wrap.cxx:5549:12: required from ‘static int swig::traits_asptr_stdseq<Seq, T>::asptr(PyObject*, swig::traits_asptr_stdseq<Seq, T>::sequence**) [with Seq = std::vector<Avoid::Point>; T = Avoid::Point; PyObject = _object; swig::traits_asptr_stdseq<Seq, T>::sequence = std::vector<Avoid::Point>]’
adaptagrams_wrap.cxx:5610:52: required from ‘static int swig::traits_asptr<std::vector<T> >::asptr(PyObject*, std::vector<T>**) [with T = Avoid::Point; PyObject = _object]’
adaptagrams_wrap.cxx:4398:37: required from ‘int swig::asptr(PyObject*, Type**) [with Type = std::vector<Avoid::Point>; PyObject = _object]’
adaptagrams_wrap.cxx:37901:34: required from here
adaptagrams_wrap.cxx:4481:8: warning: ‘void* memset(void*, int, size_t)’ clearing an object of non-trivial type ‘class Avoid::Point’; use assignment or value-initialization instead [-Wclass-memaccess]
memset(v_def,0,sizeof(Type));
~~~~~~^~~~~~~~~~~~~~~~~~~~~~
In file included from ./libavoid/libavoid.h:39,
from adaptagrams_wrap.cxx:3736:
./libavoid/geomtypes.h:52:20: note: ‘class Avoid::Point’ declared here
class AVOID_EXPORT Point
^~~~~
adaptagrams_wrap.cxx: In instantiation of ‘static Type swig::traits_as<Type, swig::pointer_category>::as(PyObject*, bool) [with Type = Avoid::Checkpoint; PyObject = _object]’:
adaptagrams_wrap.cxx:4506:64: required from ‘Type swig::as(PyObject*, bool) [with Type = Avoid::Checkpoint; PyObject = _object]’
adaptagrams_wrap.cxx:5073:20: required from ‘swig::SwigPySequence_Ref<T>::operator T() const [with T = Avoid::Checkpoint]’
adaptagrams_wrap.cxx:5527:30: required from ‘void swig::assign(const SwigPySeq&, Seq*) [with SwigPySeq = swig::SwigPySequence_Cont<Avoid::Checkpoint>; Seq = std::vector<Avoid::Checkpoint>]’
adaptagrams_wrap.cxx:5549:12: required from ‘static int swig::traits_asptr_stdseq<Seq, T>::asptr(PyObject*, swig::traits_asptr_stdseq<Seq, T>::sequence**) [with Seq = std::vector<Avoid::Checkpoint>; T = Avoid::Checkpoint; PyObject = _object; swig::traits_asptr_stdseq<Seq, T>::sequence = std::vector<Avoid::Checkpoint>]’
adaptagrams_wrap.cxx:5610:52: required from ‘static int swig::traits_asptr<std::vector<T> >::asptr(PyObject*, std::vector<T>**) [with T = Avoid::Checkpoint; PyObject = _object]’
adaptagrams_wrap.cxx:4398:37: required from ‘int swig::asptr(PyObject*, Type**) [with Type = std::vector<Avoid::Checkpoint>; PyObject = _object]’
adaptagrams_wrap.cxx:39817:34: required from here
adaptagrams_wrap.cxx:4481:8: warning: ‘void* memset(void*, int, size_t)’ clearing an object of non-trivial type ‘class Avoid::Checkpoint’; use assignment or value-initialization instead [-Wclass-memaccess]
memset(v_def,0,sizeof(Type));
~~~~~~^~~~~~~~~~~~~~~~~~~~~~
In file included from ./libavoid/libavoid.h:41,
from adaptagrams_wrap.cxx:3736:
./libavoid/connector.h:68:20: note: ‘class Avoid::Checkpoint’ declared here
class AVOID_EXPORT Checkpoint
^~~~~~~~~~
adaptagrams_wrap.cxx: In function ‘void SWIG_Python_FixMethods(PyMethodDef*, swig_const_info*, swig_type_info**, swig_type_info**)’:
adaptagrams_wrap.cxx:76503:22: warning: ‘char* strncpy(char*, const char*, size_t)’ output truncated before terminating nul copying 10 bytes from a string of the same length [-Wstringop-truncation]
strncpy(buff, "swig_ptr: ", 10);
Do you know why it fails?
I tried to run configure with ./configure CXXFLAGS="-O3 -DNDEBUG -arch x86_64 -arch i386" LDFLAGS="-arch x86_64 -arch i386"
(this is commented in the autogen.sh file) but configure fails as -arch
is not recognized by gcc... I am using gcc (GCC) 8.1.1 20180531
on arch linux.
Thanks!
In case anyone is interested, I've just been able to successfully build the python3 interface on macOS without issues. Just do following after running autogen.sh
and sudo make install
- change Makefile-swig-python to support
python3
, basically just adding a3
to the end python as follows:
$ git diff Makefile-swig-python
diff --git a/cola/Makefile-swig-python b/cola/Makefile-swig-python
index 822b415..6ca727b 100644
--- a/cola/Makefile-swig-python
+++ b/cola/Makefile-swig-python
@@ -15,7 +15,7 @@ adaptagrams_wrap.cxx: clean adaptagrams.i
swig -DNDEBUG -c++ -python adaptagrams.i
adaptagrams: adaptagrams_wrap.cxx
- python swig-python-setup.py build_ext --inplace $(COMPILER)
+ python3 swig-python-setup.py build_ext --inplace $(COMPILER)
realclean: clean
- Run
./buildPythonSWIG.sh
In this case, I was using homebrew python3