Mac build and python C API

Having trouble installing or compiling FreeCAD? Get help here.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Mac build and python C API

Post by Kunda1 »

No small task keeping all platforms in sync
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
FreddyFreddy
Posts: 176
Joined: Wed Mar 09, 2022 3:15 am
Location: Oz

Re: Mac build and python C API

Post by FreddyFreddy »

doia wrote: Thu May 26, 2022 8:49 am - at what commit did your build break? If you don't know that, which approximately date, maybe we can infer the commit from this. Test earlier commits if they fail too. If they do there might be some error in your setup.
I've wound back to February and still broken.

I see brew cellar folders python@39, python@310, and a bunch of others all updated on June 10. And a bunch of others on Apr 24.
FreddyFreddy
Posts: 176
Joined: Wed Mar 09, 2022 3:15 am
Location: Oz

Re: Mac build and python C API

Post by FreddyFreddy »

I updated git branch to nearly latest and restored from Time Machine all the files in the Cellar folder that had recently been updated. That really messed brew, but a reboot magically fixed much of that. Then it was a matter of brew link various things not found, and finally brew reinstall matplotlib@3.4.3.

Prev build crapped out at about 52%, now breaks at 64% with a different error:

Code: Select all

[ 64%] Linking CXX shared library ../../../../Mod/Import/Import.so
Undefined symbols for architecture x86_64:
  "tbb::detail::r1::initialize(tbb::detail::d1::task_group_context&)", referenced from:
      Import::ImportOCAF::loadShapes(TDF_Label const&, TopLoc_Location const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool, std::__1::vector<App::DocumentObject*, std::__1::allocator<App::DocumentObject*> >&) in ImportOCAF.cpp.o
      Import::ImportOCAF::createShape(TDF_Label const&, TopLoc_Location const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::vector<App::DocumentObject*, std::__1::allocator<App::DocumentObject*> >&, bool) in ImportOCAF.cpp.o
  "tbb::detail::r1::throw_exception(tbb::detail::d0::exception_id)", referenced from:
      tbb::detail::d1::task_group_base::~task_group_base() in ImportOCAF.cpp.o
  "tbb::detail::r1::cancel_group_execution(tbb::detail::d1::task_group_context&)", referenced from:
      tbb::detail::d1::task_group_base::~task_group_base() in ImportOCAF.cpp.o
  "tbb::detail::r1::is_group_execution_cancelled(tbb::detail::d1::task_group_context&)", referenced from:
      tbb::detail::d1::task_group_base::~task_group_base() in ImportOCAF.cpp.o
  "tbb::detail::r1::wait(tbb::detail::d1::wait_context&, tbb::detail::d1::task_group_context&)", referenced from:
      tbb::detail::d1::task_group_base::~task_group_base() in ImportOCAF.cpp.o
  "tbb::detail::r1::destroy(tbb::detail::d1::task_group_context&)", referenced from:
      tbb::detail::d1::task_group_base::~task_group_base() in ImportOCAF.cpp.o
ld: symbol(s) not found for architecture x86_64
clang-13: error: linker command failed with exit code 1 (use -v to see invocation)
Will try rolling back branch a bit and report back.
FreddyFreddy
Posts: 176
Joined: Wed Mar 09, 2022 3:15 am
Location: Oz

Re: Mac build and python C API

Post by FreddyFreddy »

Rolled back my branch by some commits and got another error for some missing file.

Rolled back further and got 100% build and install.

But immediately crashed:

Code: Select all

Termination Reason:    Namespace DYLD, Code 1 Library missing
Library not loaded: @rpath/libFreeCADGui.dylib
Referenced from: /Users/USER/FreeCAD built 29_jun_2022.app/Contents/MacOS/FreeCAD
Reason: tried: '/Users/bernie/FreeCAD.app/Contents/lib/libFreeCADGui.dylib' (no such file), '/Users/bernie/FreeCAD.app/Contents/lib/libFreeCADGui.dylib' (no such file), '/usr/local/lib/libFreeCADGui.dylib' (no such file), '/usr/lib/libFreeCADGui.dylib' (no such file)
Rolled back even further and build, installed and run ok.
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Mac build and python C API

Post by Kunda1 »

Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
Jolbas
Posts: 327
Joined: Sat Mar 26, 2022 7:48 am
Location: Sweden

Re: Mac build and python C API

Post by Jolbas »

FreddyFreddy wrote: Mon Jun 27, 2022 8:53 pm I see brew cellar folders python@39, python@310, and a bunch of others all updated on June 10. And a bunch of others on Apr 24.
@FreddyFreddy did you find out which brew update that caused the python problem. I did try to downgrade python@39 to 3.9.12 with no success.
FreddyFreddy
Posts: 176
Joined: Wed Mar 09, 2022 3:15 am
Location: Oz

Re: Mac build and python C API

Post by FreddyFreddy »

Jolbas wrote: Tue Jul 05, 2022 3:35 pm @FreddyFreddy did you find out which brew update that caused the python problem. I did try to downgrade python@39 to 3.9.12 with no success.
I think what happened to me was I brew installed cpython and it splatted a bunch of brew installs. After fixup python is:
3.9.13 [/usr/local/Frameworks/Python.framework/Versions/3.9/bin/python3.9] [.cpython-39-darwin].

Then a bug introduced into the FreeCAD brew when it was upgraded to qt 5.15.5 in the previous two weeks https://forum.freecadweb.org/viewtopic.php?f=4&t=69923).

Edit a qt file and build ok, but install errors (ld: warning: direct access in function 'QtPrivate::ValueTypeIsMetaType<QList<QWidget*> ...).
User avatar
ipatch
Posts: 112
Joined: Wed Apr 08, 2020 3:40 pm
Location: dfw
Contact:

Re: Mac build and python C API

Post by ipatch »

FreddyFreddy wrote: Sun Jun 26, 2022 6:02 pm macOS 12.5 same problem now with

Code: Select all

/Users/bernie/CLionProjects/FreeCAD/src/CXX/Python3/Objects.hxx:1026:18: error: unknown type name 'Py_complex'; did you mean '_Complex'?
etc. I hadn't done a build for a few weeks.
i too just started running into this issue attempting to build freecad on macos 10.15 (intel)

i have both python@3.9 and python@3.10 installed. i have boost boost-python3 both built and linked against python@3.10 and i believe i have most if not all other deps built and linked against python@3.10

i have manually unlinked python@3.9 and manually linked python@3.10

my cmake cmd looks like the below,

```
cmake \
-DCMAKE_INSTALL_PREFIX=../../installs/0.20.release \
-DHOMEBREW_PREFIX=$bp \
-DBUILD_QT5=1 \
-DFREECAD_CREATE_MAC_APP=1 \
-DPYTHON_EXECUTABLE=$py310exe \
-DPYTHON_INCLUDE_DIR=$bp/opt/python@3.10/Frameworks/Python.framework/Headers \
-DCMAKE_PREFIX_PATH="/usr/local/opt/qt@5;$pthcoin3d;" \
-L \
../../freecad.src/
```

haven't attempted cleaning out my build cache yet, will try that now.
User avatar
ipatch
Posts: 112
Joined: Wed Apr 08, 2020 3:40 pm
Location: dfw
Contact:

Re: Mac build and python C API

Post by ipatch »

same results, seeing errors during the process around this part...

Code: Select all

 55%] Building CXX object src/Mod/Mesh/App/CMakeFiles/Mesh.dir/WildMagic4/Wm4Vector3.cpp.o
[ 55%] Building CXX object src/Mod/Part/App/CMakeFiles/Part.dir/Part2DObjectPyImp.cpp.o
[ 55%] Building CXX object src/Mod/Mesh/App/CMakeFiles/Mesh.dir/WildMagic4/Wm4Vector4.cpp.o
[ 55%] Building CXX object src/Gui/CMakeFiles/FreeCADGui.dir/AutoSaver.cpp.o
In file included from /opt/code/github/public/forks/freecad-git/freecad.src/src/Gui/ApplicationPy.cpp:39:
In file included from /opt/code/github/public/forks/freecad-git/builds/build.0.20.release/src/App/DocumentObjectPy.h:7:
In file included from /opt/code/github/public/forks/freecad-git/builds/build.0.20.release/src/App/ExtensionContainerPy.h:7:
In file included from /opt/code/github/public/forks/freecad-git/builds/build.0.20.release/src/App/PropertyContainerPy.h:7:
In file included from /opt/code/github/public/forks/freecad-git/builds/build.0.20.release/src/Base/PersistencePy.h:7:
In file included from /opt/code/github/public/forks/freecad-git/builds/build.0.20.release/src/Base/BaseClassPy.h:7:
In file included from /opt/code/github/public/forks/freecad-git/freecad.src/src/Base/PyObjectBase.h:55:
In file included from /opt/code/github/public/forks/freecad-git/freecad.src/src/CXX/Objects.hxx:42:
/opt/code/github/public/forks/freecad-git/freecad.src/src/CXX/Python3/Objects.hxx:1026:18: error: unknown type name 'Py_complex'; did you mean
      '_Complex'?
        operator Py_complex() const
                 ^~~~~~~~~~
                 _Complex
/opt/code/github/public/forks/freecad-git/freecad.src/src/CXX/Python3/Objects.hxx:1026:18: warning: '_Complex' is a C99 extension [-Wc99-extensions]
/opt/code/github/public/forks/freecad-git/freecad.src/src/CXX/Python3/Objects.hxx:1026:18: warning: plain '_Complex' requires a type specifier;
      assuming '_Complex double'
        operator Py_complex() const
                 ^
                            double
/opt/code/github/public/forks/freecad-git/freecad.src/src/CXX/Python3/Objects.hxx:1031:35: error: unknown type name 'Py_complex'; did you mean
      '_Complex'?
        Complex &operator=( const Py_complex &v )
                                  ^~~~~~~~~~
                                  _Complex
/opt/code/github/public/forks/freecad-git/freecad.src/src/CXX/Python3/Objects.hxx:1031:35: warning: '_Complex' is a C99 extension [-Wc99-extensions]
/opt/code/github/public/forks/freecad-git/freecad.src/src/CXX/Python3/Objects.hxx:1031:35: warning: plain '_Complex' requires a type specifier;
      assuming '_Complex double'
        Complex &operator=( const Py_complex &v )
                                  ^
                                             double
/opt/code/github/public/forks/freecad-git/freecad.src/src/CXX/Python3/Objects.hxx:1028:20: error: use of undeclared identifier 'PyComplex_AsCComplex'
            return PyComplex_AsCComplex( ptr() );
                   ^
/opt/code/github/public/forks/freecad-git/freecad.src/src/CXX/Python3/Objects.hxx:1033:18: error: use of undeclared identifier 'PyComplex_FromCComplex'
            set( PyComplex_FromCComplex( v ), true );
                 ^
/opt/code/github/public/forks/freecad-git/freecad.src/src/CXX/Python3/Objects.hxx:1793:31: error: use of undeclared identifier 'Py_UNICODE'
    typedef std::basic_string<Py_UNICODE> unicodestring;
                              ^
/opt/code/github/public/forks/freecad-git/freecad.src/src/CXX/Python3/Objects.hxx:1794:12: error: unknown type name 'Py_UNICODE'
    extern Py_UNICODE unicode_null_string[1];
           ^
/opt/code/github/public/forks/freecad-git/freecad.src/src/CXX/Python3/Objects.hxx:1983:15: error: unknown type name 'Py_UNICODE'
        Char( Py_UNICODE v )
              ^
/opt/code/github/public/forks/freecad-git/freecad.src/src/CXX/Python3/Objects.hxx:2021:26: error: unknown type name 'Py_UNICODE'
        Char &operator=( Py_UNICODE v )
                         ^
/opt/code/github/public/forks/freecad-git/freecad.src/src/CXX/Python3/Objects.hxx:1990:79: error: unknown type name 'Py_UNICODE'
        : Object( PyUnicode_FromKindAndData( PyUnicode_4BYTE_KIND, const_cast<Py_UNICODE*>( v.data() ),1 ), true )
                                                                              ^
/opt/code/github/public/forks/freecad-git/freecad.src/src/CXX/Python3/Objects.hxx:1990:94: error: member reference base type 'const Py::unicodestring'
      (aka 'const int') is not a structure or union
        : Object( PyUnicode_FromKindAndData( PyUnicode_4BYTE_KIND, const_cast<Py_UNICODE*>( v.data() ),1 ), true )
                                                                                            ~^~~~~
/opt/code/github/public/forks/freecad-git/freecad.src/src/CXX/Python3/Objects.hxx:1990:46: error: use of undeclared identifier 'PyUnicode_4BYTE_KIND'
        : Object( PyUnicode_FromKindAndData( PyUnicode_4BYTE_KIND, const_cast<Py_UNICODE*>( v.data() ),1 ), true )
                                             ^
/opt/code/github/public/forks/freecad-git/freecad.src/src/CXX/Python3/Objects.hxx:2010:78: error: unknown type name 'Py_UNICODE'
            set( PyUnicode_FromKindAndData( PyUnicode_4BYTE_KIND, const_cast<Py_UNICODE*>( v.data() ), 1 ), true );
                                                                             ^
/opt/code/github/public/forks/freecad-git/freecad.src/src/CXX/Python3/Objects.hxx:2010:93: error: member reference base type 'const Py::unicodestring'
      (aka 'const int') is not a structure or union
            set( PyUnicode_FromKindAndData( PyUnicode_4BYTE_KIND, const_cast<Py_UNICODE*>( v.data() ), 1 ), true );
                                                                                           ~^~~~~
/opt/code/github/public/forks/freecad-git/freecad.src/src/CXX/Python3/Objects.hxx:2010:45: error: use of undeclared identifier 'PyUnicode_4BYTE_KIND'
            set( PyUnicode_FromKindAndData( PyUnicode_4BYTE_KIND, const_cast<Py_UNICODE*>( v.data() ), 1 ), true );
                                            ^
/opt/code/github/public/forks/freecad-git/freecad.src/src/CXX/Python3/Objects.hxx:2016:13: error: unknown type name 'Py_UNICODE'
            Py_UNICODE v( v_ );
            ^
/opt/code/github/public/forks/freecad-git/freecad.src/src/CXX/Python3/Objects.hxx:2017:45: error: use of undeclared identifier 'PyUnicode_4BYTE_KIND'
            set( PyUnicode_FromKindAndData( PyUnicode_4BYTE_KIND, &v, 1 ), true );
                                            ^
/opt/code/github/public/forks/freecad-git/freecad.src/src/CXX/Python3/Objects.hxx:2023:45: error: use of undeclared identifier 'PyUnicode_4BYTE_KIND'
            set( PyUnicode_FromKindAndData( PyUnicode_4BYTE_KIND, &v, 1 ), true );
                                            ^
/opt/code/github/public/forks/freecad-git/freecad.src/src/CXX/Python3/Objects.hxx:2116:23: error: unknown type name 'Py_UNICODE'
        String( const Py_UNICODE *s, int length )
                      ^
/opt/code/github/public/forks/freecad-git/freecad.src/src/CXX/Python3/Objects.hxx:2117:53: error: use of undeclared identifier 'PyUnicode_4BYTE_KIND'
        : SeqBase<Char>( PyUnicode_FromKindAndData( PyUnicode_4BYTE_KIND, s, length ), true )
                                                    ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
[ 55%] Building CXX object src/Mod/Mesh/App/CMakeFiles/Mesh.dir/AppMesh.cpp.o
[ 55%] Building CXX object src/Gui/CMakeFiles/FreeCADGui.dir/BitmapFactory.cpp.o
In file included from /opt/code/github/public/forks/freecad-git/freecad.src/src/Gui/Application.cpp:43:
In file included from /opt/code/github/public/forks/freecad-git/builds/build.0.20.release/src/App/DocumentObjectPy.h:7:
In file included from /opt/code/github/public/forks/freecad-git/builds/build.0.20.release/src/App/ExtensionContainerPy.h:7:
In file included from /opt/code/github/public/forks/freecad-git/builds/build.0.20.release/src/App/PropertyContainerPy.h:7:
In file included from /opt/code/github/public/forks/freecad-git/builds/build.0.20.release/src/Base/PersistencePy.h:7:
In file included from /opt/code/github/public/forks/freecad-git/builds/build.0.20.release/src/Base/BaseClassPy.h:7:
In file included from /opt/code/github/public/forks/freecad-git/freecad.src/src/Base/PyObjectBase.h:55:
In file included from /opt/code/github/public/forks/freecad-git/freecad.src/src/CXX/Objects.hxx:42:
/opt/code/github/public/forks/freecad-git/freecad.src/src/CXX/Python3/Objects.hxx:1026:18: error: unknown type name 'Py_complex'; did you mean
      '_Complex'?
        operator Py_complex() const
                 ^~~~~~~~~~
                 _Complex
/opt/code/github/public/forks/freecad-git/freecad.src/src/CXX/Python3/Objects.hxx:1026:18: warning: '_Complex' is a C99 extension [-Wc99-extensions]
/opt/code/github/public/forks/freecad-git/freecad.src/src/CXX/Python3/Objects.hxx:1026:18: warning: plain '_Complex' requires a type specifier;
      assuming '_Complex double'
        operator Py_complex() const
                 ^
                            double
/opt/code/github/public/forks/freecad-git/freecad.src/src/CXX/Python3/Objects.hxx:1031:35: error: unknown type name 'Py_complex'; did you mean
      '_Complex'?
        Complex &operator=( const Py_complex &v )
                                  ^~~~~~~~~~
                                  _Complex
/opt/code/github/public/forks/freecad-git/freecad.src/src/CXX/Python3/Objects.hxx:1031:35: warning: '_Complex' is a C99 extension [-Wc99-extensions]
/opt/code/github/public/forks/freecad-git/freecad.src/src/CXX/Python3/Objects.hxx:1031:35: warning: plain '_Complex' requires a type specifier;
      assuming '_Complex double'
        Complex &operator=( const Py_complex &v )
                                  ^
                                             double
/opt/code/github/public/forks/freecad-git/freecad.src/src/CXX/Python3/Objects.hxx:1028:20: error: use of undeclared identifier 'PyComplex_AsCComplex'
            return PyComplex_AsCComplex( ptr() );
                   ^
/opt/code/github/public/forks/freecad-git/freecad.src/src/CXX/Python3/Objects.hxx:1033:18: error: use of undeclared identifier 'PyComplex_FromCComplex'
            set( PyComplex_FromCComplex( v ), true );
                 ^
/opt/code/github/public/forks/freecad-git/freecad.src/src/CXX/Python3/Objects.hxx:1793:31: error: use of undeclared identifier 'Py_UNICODE'
    typedef std::basic_string<Py_UNICODE> unicodestring;
                              ^
/opt/code/github/public/forks/freecad-git/freecad.src/src/CXX/Python3/Objects.hxx:1794:12: error: unknown type name 'Py_UNICODE'
    extern Py_UNICODE unicode_null_string[1];
           ^
/opt/code/github/public/forks/freecad-git/freecad.src/src/CXX/Python3/Objects.hxx:1983:15: error: unknown type name 'Py_UNICODE'
        Char( Py_UNICODE v )
              ^
/opt/code/github/public/forks/freecad-git/freecad.src/src/CXX/Python3/Objects.hxx:2021:26: error: unknown type name 'Py_UNICODE'
        Char &operator=( Py_UNICODE v )
                         ^
/opt/code/github/public/forks/freecad-git/freecad.src/src/CXX/Python3/Objects.hxx:1990:79: error: unknown type name 'Py_UNICODE'
        : Object( PyUnicode_FromKindAndData( PyUnicode_4BYTE_KIND, const_cast<Py_UNICODE*>( v.data() ),1 ), true )
                                                                              ^
/opt/code/github/public/forks/freecad-git/freecad.src/src/CXX/Python3/Objects.hxx:1990:94: error: member reference base type 'const Py::unicodestring'
      (aka 'const int') is not a structure or union
        : Object( PyUnicode_FromKindAndData( PyUnicode_4BYTE_KIND, const_cast<Py_UNICODE*>( v.data() ),1 ), true )
                                                                                            ~^~~~~
/opt/code/github/public/forks/freecad-git/freecad.src/src/CXX/Python3/Objects.hxx:1990:46: error: use of undeclared identifier 'PyUnicode_4BYTE_KIND'
        : Object( PyUnicode_FromKindAndData( PyUnicode_4BYTE_KIND, const_cast<Py_UNICODE*>( v.data() ),1 ), true )
                                             ^
/opt/code/github/public/forks/freecad-git/freecad.src/src/CXX/Python3/Objects.hxx:2010:78: error: unknown type name 'Py_UNICODE'
            set( PyUnicode_FromKindAndData( PyUnicode_4BYTE_KIND, const_cast<Py_UNICODE*>( v.data() ), 1 ), true );
                                                                             ^
/opt/code/github/public/forks/freecad-git/freecad.src/src/CXX/Python3/Objects.hxx:2010:93: error: member reference base type 'const Py::unicodestring'
      (aka 'const int') is not a structure or union
            set( PyUnicode_FromKindAndData( PyUnicode_4BYTE_KIND, const_cast<Py_UNICODE*>( v.data() ), 1 ), true );
                                                                                           ~^~~~~
/opt/code/github/public/forks/freecad-git/freecad.src/src/CXX/Python3/Objects.hxx:2010:45: error: use of undeclared identifier 'PyUnicode_4BYTE_KIND'
            set( PyUnicode_FromKindAndData( PyUnicode_4BYTE_KIND, const_cast<Py_UNICODE*>( v.data() ), 1 ), true );
                                            ^
/opt/code/github/public/forks/freecad-git/freecad.src/src/CXX/Python3/Objects.hxx:2016:13: error: unknown type name 'Py_UNICODE'
            Py_UNICODE v( v_ );
            ^
/opt/code/github/public/forks/freecad-git/freecad.src/src/CXX/Python3/Objects.hxx:2017:45: error: use of undeclared identifier 'PyUnicode_4BYTE_KIND'
            set( PyUnicode_FromKindAndData( PyUnicode_4BYTE_KIND, &v, 1 ), true );
                                            ^
/opt/code/github/public/forks/freecad-git/freecad.src/src/CXX/Python3/Objects.hxx:2023:45: error: use of undeclared identifier 'PyUnicode_4BYTE_KIND'
            set( PyUnicode_FromKindAndData( PyUnicode_4BYTE_KIND, &v, 1 ), true );
                                            ^
/opt/code/github/public/forks/freecad-git/freecad.src/src/CXX/Python3/Objects.hxx:2116:23: error: unknown type name 'Py_UNICODE'
        String( const Py_UNICODE *s, int length )
                      ^
/opt/code/github/public/forks/freecad-git/freecad.src/src/CXX/Python3/Objects.hxx:2117:53: error: use of undeclared identifier 'PyUnicode_4BYTE_KIND'
        : SeqBase<Char>( PyUnicode_FromKindAndData( PyUnicode_4BYTE_KIND, s, length ), true )
                                                    ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
[ 55%] Building CXX object src/Mod/Mesh/App/CMakeFiles/Mesh.dir/AppMeshPy.cpp.o
4 warnings and 20 errors generated.
make[2]: *** [src/Gui/CMakeFiles/FreeCADGui.dir/ApplicationPy.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....

FreddyFreddy
Posts: 176
Joined: Wed Mar 09, 2022 3:15 am
Location: Oz

Re: Mac build and python C API

Post by FreddyFreddy »

Post Reply