DevHeads.net

Need help: SWIG related build error for python-pivy?

I'm working on packaging Coin4 for Fedora as it is needed for FreeCAD.

I have both SoQt and SIMVoleon buliding with it but I'm getting an error
with Pivy:

+ /usr/bin/python3 setup.py build '--executable=/usr/bin/python3 -s'
running build
BUILDSTDERR: Deprecated command line option: -modern. This option is now
always on.
BUILDSTDERR: Inventor/SbDict.h:53: Error: Unable to find 'cstddef'
BUILDSTDERR: Inventor/SbString.h:40: Error: Unable to find 'cstdarg'
BUILDSTDERR: Inventor/lists/SbPList.h:41: Error: Unable to find 'cassert'
BUILDSTDERR: Inventor/lists/SbPList.h:42: Error: Unable to find 'cstddef'
BUILDSTDERR: /usr/include/Coin4/Inventor/lists/SbList.h:36: Error: Unable
to find 'cassert'
BUILDSTDERR: /usr/include/Coin4/Inventor/lists/SbList.h:37: Error: Unable
to find 'cstddef'
BUILDSTDERR: /usr/include/Coin4/Inventor/elements/SoSubElement.h:51: Error:
Unable to find 'cassert'
BUILDSTDERR: /usr/include/Coin4/Inventor/misc/SoState.h:38: Error: Unable
to find 'cassert'
BUILDSTDERR: /usr/include/Coin4/Inventor/fields/SoSubField.h:39: Error:
Unable to find 'cassert'
BUILDSTDERR: /usr/include/Coin4/Inventor/SbBSPTree.h:36: Error: Unable to
find 'cstddef'
BUILDSTDERR: /usr/include/Coin4/Inventor/elements/SoNormalElement.h:38:
Error: Unable to find 'cassert'
BUILDSTDERR: /usr/include/Coin4/Inventor/caches/SoCache.h:41: Error: Unable
to find 'cstddef'
BUILDSTDERR: /usr/include/Coin4/Inventor/details/SoSubDetail.h:40: Error:
Unable to find 'cassert'
BUILDSTDERR:
/usr/include/Coin4/Inventor/elements/SoProfileCoordinateElement.h:39:
Error: Unable to find 'cassert'
BUILDSTDERR: /usr/include/Coin4/Inventor/engines/SoSubEngine.h:36: Error:
Unable to find 'cassert'
BUILDSTDERR: /usr/include/Coin4/Inventor/misc/SoGLImage.h:47: Error: Unable
to find 'cstddef'
BUILDSTDERR: /usr/include/Coin4/Inventor/nodes/SoExtSelection.h:39: Error:
Unable to find 'cstddef'
BUILDSTDERR: /usr/include/Coin4/Inventor/SbClip.h:38: Error: Unable to find
'cstddef'
BUILDSTDERR: /usr/include/Coin4/Inventor/SbHeap.h:38: Error: Unable to find
'cstddef'
BUILDSTDERR: Inventor/SbImage.h:43: Error: Unable to find 'cstddef'
BUILDSTDERR: /usr/include/Coin4/Inventor/SbTesselator.h:39: Error: Unable
to find 'cstddef'

...

=== Generating pivy/coin_wrap.cpp for coin ===
swig -w302,306,307,312,314,325,361,362,467,389,503,509,510 -py3 -c++
-python -includeall -modern -D__PIVY__ -I. -Ifake_headers
-I"/usr/include/Coin4" -Iinterfaces -o pivy/coin_wrap.cpp interfaces/coin.i
SWIG did not generate wrappers successfully! ** Aborting **

All of these are "released" by the same upstream but Pivy has not had a
release for a while so I'm using the latest checkout which includes fixes
for Python 3 and Freecad.

<a href="https://bitbucket.org/%7B33c4279a-271f-4864-88ce-03ec8eb2cafc%7D/" title="https://bitbucket.org/%7B33c4279a-271f-4864-88ce-03ec8eb2cafc%7D/">https://bitbucket.org/%7B33c4279a-271f-4864-88ce-03ec8eb2cafc%7D/</a>

I just did a local mock build of the current python-pivy with Coin3 to make
sure the problem didn't lie elsewhere...

Any help/tips would be appreciated.

Thanks,
Richard

Comments

Re: Need help: SWIG related build error for python-pivy?

By Jerry James at 09/05/2019 - 21:18

On Thu, Sep 5, 2019 at 7:53 PM Richard Shaw < ... at gmail dot com> wrote:
The errors indicate that the compiler cannot find the standard C++
headers. These are the first things I would check:
1. Does the spec file include BuildRequires: gcc-c++?
2. Is setup.py choosing g++ as the compiler?
3. Is -nostdinc++ showing up in the build flags?

If all of those check out, maybe you could share your spec files.

Re: Need help: SWIG related build error for python-pivy?

By Richard Shaw at 09/12/2019 - 11:50

I didn't (hadn't needed it before) but I added it with no change to the
errors...

I can't tell, it's just running swig with the -c++ option which is correct.
I don't know what swig is doing in the background...

Not that I can tell...

Thanks,
Richard

Re: Need help: SWIG related build error for python-pivy?

By Jerry James at 09/13/2019 - 10:35

On Thu, Sep 12, 2019 at 10:51 AM Richard Shaw < ... at gmail dot com> wrote:
Okay, and then I also said:

I'm happy to help you look at this, but you'll need to provide a way
to reproduce the issue.

Re: Need help: SWIG related build error for python-pivy?

By Richard Shaw at 09/13/2019 - 10:52

I actually did make some progress... Pivy currently passes -includeall to
swig, and from my googling that's generally a bad idea so I'm applying a
patch to remove it.

I still don't know much about swig but my understanding is that keeps it
from trying to process all the headers and instead just the ones in the
swig template.

Now the error is narrowed down to:

But it's erroring on the second 2nd binding (and there's many more)

=== Generating pivy/coin_wrap.cpp for coin ===
swig -w302,306,307,312,314,325,361,362,467,389,503,509,510 -py3 -c++
-python -D__PIVY__ -I. -Ifake_headers -I"/usr/include" -Iinterfaces -o
pivy/coin_wrap.cpp interfaces/coin.i
=== Generating pivy/gui/soqt_wrap.cpp for soqt ===
swig -w302,306,307,312,314,325,361,362,467,389,503,509,510 -py3 -c++
-python -D__PIVY__ -I. -Ifake_headers -I"/usr/include" -Iinterfaces -o
pivy/gui/soqt_wrap.cpp interfaces/soqt.i
SWIG did not generate wrappers successfully! ** Aborting **

BUILDSTDERR: Inventor/fields/SoField.i:10: Warning 303: %extend defined for
an undeclared class SoField.
BUILDSTDERR: Inventor/SbString.i:17: Warning 303: %extend defined for an
undeclared class SbString.
BUILDSTDERR: /usr/include/Inventor/Qt/devices/SoQtDevice.h:73: Error:
Syntax error in input(1).

Next I'm going to patch it to run swig with debugging so I can get more
details... My guess is there was an incompatible change between Coin3 and
Coin4 but I'm running the latest checkout of Pivy and it's all the same
upstream. If that's the case then they messed up.

Thanks,
Richard

Re: Need help: SWIG related build error for python-pivy?

By Richard Shaw at 09/13/2019 - 13:28

I can put the packages somewhere online but you have to build the whole
chain... I'll try a little longer to manage it here and if you need more
info maybe I'll setup a COPR...

Looking at a section of the file and line number from the error I see the
following, with the line in question (73) being the "class SOQT_DLL_API"
line:

#include <Inventor/SbLinear.h>
#include <Inventor/Qt/SoQtObject.h>

class SoEvent;

// *************************************************************************

class SOQT_DLL_API SoQtDevice : public SoQtObject {
SOQT_OBJECT_ABSTRACT_HEADER(SoQtDevice, SoQtObject);

public:
virtual ~SoQtDevice();

virtual void enable(QWidget* w, SoQtEventHandler * handler, void *
closure) = 0;
virtual void disable(QWidget* w, SoQtEventHandler * handler, void *
closure) = 0;

virtual const SoEvent * translateEvent(QEvent* event) = 0;

void setWindowSize(const SbVec2s size);
SbVec2s getWindowSize(void) const;

static void initClasses(void);

protected:
SoQtDevice(void);

void setEventPosition(SoEvent * event, int x, int y) const;
static SbVec2s getLastEventPosition(void);

void addEventHandler(QWidget*, SoQtEventHandler *, void *);
void removeEventHandler(QWidget*, SoQtEventHandler *, void *);
void invokeHandlers(QEvent* event);

private:
class SoQtDeviceP * pimpl;
friend class SoQtDeviceP;
};

I also ran a diff from the same Pivy compiled with Coin3 and Coin4 and the
ONLY significant difference is where the asterisk is on the QWidget lines:

Coin3: ...(QWidget *...
Coin4: ...(QWidget*...

Does the space between QWidget and asterisk make a difference?

Thanks,
Richard

Re: Need help: SWIG related build error for python-pivy?

By Kevin Kofler at 09/14/2019 - 04:44

Richard Shaw wrote:
It should not. The C++ compiler does not care either way, it is the same
type. Whitespace is not syntactic in C/C++, unless it splits a token into 2
(e.g. "long int").

QWidget *foo, QWidget* foo, QWidget*foo, and QWidget * foo are all valid
ways to spell the same declaration.

QWidget *foo is really how the language works, e.g., you have to write
QWidget *foo, *bar; to get 2 pointers, QWidget* foo, bar; will be read as
QWidget *foo, bar; and give you only one pointer and one stack-allocated
object. So IMHO QWidget *foo is the correct way to write it. But many
developers prefer QWidget* foo because they say the * is part of the type
and should be attached to the type.

Kevin Kofler

Re: Need help: SWIG related build error for python-pivy?

By Richard Shaw at 09/14/2019 - 07:23

I need to learn more C/C++ one of these days...

Long story short the difference was due to autotools vs. CMake
implementation, not the version of Coin. I even patched CMake to produce
the same output as the Coin3 version of the file so they were identical
other than comments. It's still choking on the same file.

Getting frustrated with SWIG's lack of useful error output. I've tried
patching in a few different debug option but it hasn't produced anything
useful.

If I remove "-includeall" from SWIG I get rid of the missing standard c++
include problems but then it produces:

BUILDSTDERR: /usr/include/Inventor/Qt/devices/SoQtDevice.h:73: Error:
Syntax error in input(1).

This only place this error is mentioned in the SWIG documentation is in the
Warnings section, which is funny because it's an error not a warning and
it's used an example of warning output, no further details given. On
googling it, I've read that the line number is not reliable if macros are
involved so I really don't know where to look.

Because I'm having ot build a stack of programs at once using mockchain I
figured this would be a good time to try out toolbox. It works from my
regular login but when I su login to my build user (I do all my packaging
work separately from my main login) it doesn't work:

$ toolbox list
toolbox: unable to migrate containers: runtime directory not created

Looks like it needs to mature a bit.

Thanks,
Richard

Re: Need help: SWIG related build error for python-pivy?

By Richard Shaw at 09/15/2019 - 09:54

Well I'm not sure exactly what the problem was, but I got it fixed.

I moved to the FreeCAD fork of Pivy which is actually maintained. Since I
originally packaged Pivy for FreeCAD it makes sense to use it anyway.

Thanks,
Richard