Fedora build error with GeometryPyCXX.cpp

Having trouble installing or compiling FreeCAD? Get help here.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
hobbes1069
Posts: 291
Joined: Wed Nov 09, 2011 3:49 pm
Location: Southaven, MS

Fedora build error with GeometryPyCXX.cpp

Post by hobbes1069 »

I was able to build 0.17 pre-release but got this error trying to build the 0.17 release.

The only difference I'm aware of on my side is trying to use zipios 2.X instead of the old 0.1.5.9 (it's unbundled on Fedora), but I'm not sure that's relevant to this error.

Code: Select all

BUILDSTDERR: /builddir/build/BUILD/FreeCAD-0.17/src/Base/GeometryPyCXX.cpp: In member function 'virtual int Base::Vector2dPy::setattro(const Py::String&, const Py::Object&)':
BUILDSTDERR: /builddir/build/BUILD/FreeCAD-0.17/src/Base/GeometryPyCXX.cpp:157:31: error: 'const class Py::Object' has no member named 'isNull'; did you mean 'isNone'?
BUILDSTDERR:      if (name == "x" && !value.isNull()) {
BUILDSTDERR:                                ^~~~~~
BUILDSTDERR:                                isNone
BUILDSTDERR: /builddir/build/BUILD/FreeCAD-0.17/src/Base/GeometryPyCXX.cpp:161:36: error: 'const class Py::Object' has no member named 'isNull'; did you mean 'isNone'?
BUILDSTDERR:      else if (name == "y" && !value.isNull()) {
BUILDSTDERR:                                     ^~~~~~
BUILDSTDERR:                                     isNone
Thanks,
Richard
User avatar
hobbes1069
Posts: 291
Joined: Wed Nov 09, 2011 3:49 pm
Location: Southaven, MS

Re: Fedora build error with GeometryPyCXX.cpp

Post by hobbes1069 »

I figured out part of the problem. With PyCXX 7.0+ there's a new source file required: cxx_exceptions.cxx

Now I'm getting:

Code: Select all

[ 26%] Building CXX object src/App/CMakeFiles/FreeCADApp.dir/GroupExtensionPyImp.cpp.o
cd /builddir/build/BUILD/FreeCAD-0.17/build/src/App && /usr/bin/c++  -DBOOST_106600 -DDOCDIR=\"/usr/share/doc/freecad\" -DFreeCADApp_EXPORTS -DHAVE_CONFIG_H -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_SVG_LIB -DQT_UITOOLS_LIB -DQT_WEBKIT_LIB -DQT_XML_LIB -DRESOURCEDIR=\"/usr/share/freecad\" -D_OCC64 -I/builddir/build/BUILD/FreeCAD-0.17/build -I/usr/include/smesh -isystem /usr/include/QtOpenGL -isystem /usr/include/QtSvg -isystem /usr/include/QtUiTools -isystem /usr/include/QtWebKit -isystem /usr/include/QtGui -isystem /usr/include/QtXml -isystem /usr/include/QtNetwork -isystem /usr/include/QtCore -I/builddir/build/BUILD/FreeCAD-0.17/build/src -I/builddir/build/BUILD/FreeCAD-0.17/src -I/builddir/build/BUILD/FreeCAD-0.17/build/src/App -I/usr/include/python2.7  -Wall -Wextra -Wno-write-strings -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -mcet -fcf-protection -std=c++11 -D_OCC64 -fPIC   -o CMakeFiles/FreeCADApp.dir/GroupExtensionPyImp.cpp.o -c /builddir/build/BUILD/FreeCAD-0.17/src/App/GroupExtensionPyImp.cpp
/builddir/build/BUILD/FreeCAD-0.17/src/App/ExtensionContainerPyImp.cpp: In member function 'PyObject* App::ExtensionContainerPy::hasExtension(PyObject*)':
/builddir/build/BUILD/FreeCAD-0.17/src/App/ExtensionContainerPyImp.cpp:161:70: error: no matching function for call to 'Py::Exception::Exception(PyObject*&, std::__cxx11::basic_stringstream<char>::__string_type)'
         throw Py::Exception(Base::BaseExceptionFreeCADError,str.str());
                                                                      ^
wmayer
Founder
Posts: 20307
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Fedora build error with GeometryPyCXX.cpp

Post by wmayer »

I assume on Fedora the pycxx lib has its own package which you have installed. You can configure FreeCAD to use the system pycxx version by setting PYCXX_INCLUDE_DIR and PYCXX_SOURCE_DIR accordingly.

But I don't think this will fix the first build error inside GeometryPyCXX.cpp.

Another option might be to uninstall the pycxx package and use FreeCAD's one.
User avatar
hobbes1069
Posts: 291
Joined: Wed Nov 09, 2011 3:49 pm
Location: Southaven, MS

Re: Fedora build error with GeometryPyCXX.cpp

Post by hobbes1069 »

Yes, I need to use the Fedora version if at all possible. Bundling exceptions require approval by the Fedora Packaging Committee.

I've been using the PYCXX_* options to build against the system version for some time but Rawhide (f29) has been updated to PyCXX 7.0.3.

I'm working on FindPyCXX.cmake to detect the version and add the extra source if >=7.0.0 but that's a dead end unless the FreeCAD source can be updated to work with either version.

Thanks,
Richard
User avatar
hobbes1069
Posts: 291
Joined: Wed Nov 09, 2011 3:49 pm
Location: Southaven, MS

Re: Fedora build error with GeometryPyCXX.cpp

Post by hobbes1069 »

Answer from CXX upstream[1]:
> On 17 Apr 2018, at 14:07, Richard Shaw <hobbes1069@...> wrote:
>
> BUILDSTDERR: throw Py::Exception(Base::BaseExceptionFreeCADError,str.str());

You have two ways to proceed.

1) define PYCXX_6_2_COMPATIBILITY and use the old API
2) port to the V7 API - have a look at CXX/Python2/Exception.hxx
and the PYCXX_USER_EXCEPTION_xxx macros.

Oh and you might find the brief notes in the readme informative.

http://cxx.sourceforge.net/README.html <http://cxx.sourceforge.net/>;
I'm trying adding a command line definition in the spec file on Fedora for the temporary fix. Can we do some version checking with CXX/Version.hxx and add the define when needed until FreeCAD gets ported to the 7.X API?

Thanks,
Richard

[1] https://sourceforge.net/p/cxx/mailman/message/36296392/
wmayer
Founder
Posts: 20307
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Fedora build error with GeometryPyCXX.cpp

Post by wmayer »

Here is a brief tutorial how to use the Fedora PyCXX package:
  1. From the FreeCAD source tarball remove the CXX directory. This is to avoid that the compiler may include a wrong header file.
  2. Set PYCXX_INCLUDE_DIR and PYCXX_SOURCE_DIR to point to the header and source files of the PyCXX package
  3. Edit FindPyCXX.cmake and add the file cxx_exceptions.cxx. See line 99ff.

    Code: Select all

    ${PYCXX_SOURCE_DIR}/cxx_exceptions.cxx
    
  4. Edit the top-level CMakeLists.txt file and add this line

    Code: Select all

    add_definitions(-DPYCXX_6_2_COMPATIBILITY)
    
  5. Now you get some build failures because Py::Exception(const std::string &) doesn't exist any more. Here you can replace Py::Exception with Py::RuntimeError.
User avatar
hobbes1069
Posts: 291
Joined: Wed Nov 09, 2011 3:49 pm
Location: Southaven, MS

Re: Fedora build error with GeometryPyCXX.cpp

Post by hobbes1069 »

Is there a good way to generalize the last part? Right now I'm trying a brute force grep for one and sed replace with the other.

I've added all the cmake logic to add cxx_exceptions if CXX >= 7.0.0 including adding the definition. Just need to figure out the last part and I can make this a pull request.

Thanks,
Richard
wmayer
Founder
Posts: 20307
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Fedora build error with GeometryPyCXX.cpp

Post by wmayer »

Wait! At the moment I am building the master branch against PyCXX 7.0.3 and almost fixed most of the build failures. Just need to wait until it's completed before I can check it in.
Is there a good way to generalize the last part? Right now I'm trying a brute force grep for one and sed replace with the other.
This won't work because it only fails for these cases where Py::Exception is used with a single argument.
wmayer
Founder
Posts: 20307
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Fedora build error with GeometryPyCXX.cpp

Post by wmayer »

wmayer wrote: Wed Apr 18, 2018 4:54 pm Wait! At the moment I am building the master branch against PyCXX 7.0.3 and almost fixed most of the build failures. Just need to wait until it's completed before I can check it in.
Is there a good way to generalize the last part? Right now I'm trying a brute force grep for one and sed replace with the other.
This won't work because it only fails for these cases where Py::Exception is used with a single argument.
EDIT: Try this git commit 840c9e8b
User avatar
hobbes1069
Posts: 291
Joined: Wed Nov 09, 2011 3:49 pm
Location: Southaven, MS

Re: Fedora build error with GeometryPyCXX.cpp

Post by hobbes1069 »

that got that problem sorted!

I should probably submit my cmake patch which detects the CXX version from the Version.hxx header and adds cxx_exception.cpp to the sources if >=7 is detected.

Now I'm having a problem with smesh I'm guessing, but I'll post that to another thread.

Thanks,
Richard
Post Reply