Implicit instatiation error MacOS

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
Jolbas
Posts: 327
Joined: Sat Mar 26, 2022 7:48 am
Location: Sweden

Implicit instatiation error MacOS

Post by Jolbas »

Hello
I'm trying to compile on MacOS 12.6.2 according to this guide
I get the following error:

Code: Select all

[ 15%] Building CXX object src/Gui/CMakeFiles/FreeCADGui.dir/SoFCSelection.cpp.o
~/FreeCAD/freecad-source/src/Gui/SoFCSelection.cpp:385:28: error: implicit instantiation of undefined template 'std::array<std::pair<double, std::string>, 3>'
                auto pts = schemaTranslatePoint(pt[0], pt[1], pt[2], 1e-7);
                           ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/include/c++/v1/__tuple:219:64: note: template is declared here
template <class _Tp, size_t _Size> struct _LIBCPP_TEMPLATE_VIS array;
                                                               ^
1 error generated.
make[2]: *** [src/Gui/CMakeFiles/FreeCADGui.dir/SoFCSelection.cpp.o] Error 1
make[1]: *** [src/Gui/CMakeFiles/FreeCADGui.dir/all] Error 2
make: *** [all] Error 2
Searching for the error indicates this is due to missing include or wrong c++ version. I do indeed get pass the error by adding

Code: Select all

#include <array>
in the beginning of SoFCSelection.cpp but it doesn't feel right and soon after I have a new similar error in another file
The #include <array> also make a way past this errors:

Code: Select all

/Users/bj/FreeCAD/freecad-source/src/Mod/TechDraw/App/DrawProjGroup.cpp:923:17: error: type 'std::array<DrawProjGroupItem *, MAXPROJECTIONCOUNT>' does not provide a subscript operator
        viewPtrs[i] = nullptr;
        ~~~~~~~~^~
/Users/bj/FreeCAD/freecad-source/src/Mod/TechDraw/App/DrawProjGroup.cpp:967:29: error: type 'std::array<DrawProjGroupItem *, MAXPROJECTIONCOUNT>' does not provide a subscript operator
                    viewPtrs[4] = oView;
                    ~~~~~~~~^~
I can make it through the entire build just adding #include <array> but the resulting app won't start.

This is my cmake arguments:

Code: Select all

cmake \
  -DCMAKE_BUILD_TYPE="Release" \
  -DPYTHON_EXECUTABLE="/usr/local/bin/python3.10" \
  -DPYTHON_INCLUDE_DIR="/usr/local/opt/python/Frameworks/Python.framework/Versions/3.10/include/python3.10" \
  -DQt5_DIR="/usr/local/Cellar/qt@5/5.15.8_1/lib/cmake/Qt5" \
  -DPySide2_DIR="/usr/local/Cellar/pyside@2/5.15.8/lib/cmake/PySide2-5.15.5" \
  -DShiboken2_DIR="/usr/local/Cellar/shiboken2@5.15.5/5.15.5_1/lib/cmake/Shiboken2-5.15.5" \
  ../freecad-source
User avatar
chennes
Veteran
Posts: 3877
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Implicit instatiation error MacOS

Post by chennes »

I was able to get past this by adding a new include at the top:

Code: Select all

#include <array>
ETA: And my app works fine, though I had to make a couple other changes to finish the compile.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
User avatar
Jolbas
Posts: 327
Joined: Sat Mar 26, 2022 7:48 am
Location: Sweden

Re: Implicit instatiation error MacOS

Post by Jolbas »

chennes wrote: Wed Feb 08, 2023 2:33 am ... my app works fine, though I had to make a couple other changes to finish the compile.
It works for me now too. There was another error preventing the app from starting.

Is there a way to handle this in git? I need the adjustments locally to build but I don't want to include them in a PR.
User avatar
Jolbas
Posts: 327
Joined: Sat Mar 26, 2022 7:48 am
Location: Sweden

Re: Implicit instatiation error MacOS

Post by Jolbas »

@chennes If you also need to add

Code: Select all

#include <array>
at the top of those files, is this something that should be committed to master? No one else seem to have this problem which makes me think this is due to configuration. There is no such line in Gui/PreCompiled.h either but std::array is apparently used. I have to add the include in the following files:

Code: Select all

Gui/Selection.cpp
Gui/SoFCSelection.cpp
Gui/SoFCUnifiedSelection.cpp
Gui/ViewProviderLink.cpp
Mod/Import/App/ImportOCAF2.cpp
Mod/TechDraw/App/DrawProjGroup.cpp
I doesn't work adding the line in Gui/PreCompiled.h even though that file is included.
User avatar
chennes
Veteran
Posts: 3877
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Implicit instatiation error MacOS

Post by chennes »

Do all of those files have a use of std::array in them? Or are they including something that does?
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
User avatar
Jolbas
Posts: 327
Joined: Sat Mar 26, 2022 7:48 am
Location: Sweden

Re: Implicit instatiation error MacOS

Post by Jolbas »

chennes wrote: Fri Mar 17, 2023 1:08 pm Do all of those files have a use of std::array in them? Or are they including something that does?
The three selection related files all have this function:

Code: Select all

std::array<std::pair<double, std::string>,3 > schemaTranslatePoint(double x, double y, double z, double precision);
Which, based on how it's used, probably could just return a single string instead.

Mod/Import/App/ImportOCAF2.cpp using it to iterate over three strings

Code: Select all

static std::array<const char *,3> keys = {"Face*","Edge*",marker.c_str()};
...
for(auto key : keys) {
Gui/ViewProviderLink.cpp has it under public: for class Gui:LinkInfo

Code: Select all

    std::array<CoinPtr<SoSeparator>,LinkView::SnapshotMax> pcSnapshots;
    std::array<CoinPtr<SoSwitch>,LinkView::SnapshotMax> pcSwitches;
And Mod/TechDraw/App/DrawProjGroup.cpp have 18 occurences of "std::array". E.g:

Code: Select all

double DrawProjGroup::getMaxRowHeight(std::array<int, 3> list,
                                      std::array<Base::BoundBox3d, MAXPROJECTIONCOUNT> bboxes)
Those functions are declared in Mod/TechDraw/App/DrawProjGroup.h but I get no error from compiling that file.
User avatar
chennes
Veteran
Posts: 3877
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Implicit instatiation error MacOS

Post by chennes »

If they all have explicit uses of std::array then so think it would be a good idea to have that include file added. Can you make a PR?
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
User avatar
Jolbas
Posts: 327
Joined: Sat Mar 26, 2022 7:48 am
Location: Sweden

Re: Implicit instatiation error MacOS

Post by Jolbas »

chennes wrote: Sat Mar 18, 2023 3:16 pm If they all have explicit uses of std::array then so think it would be a good idea to have that include file added. Can you make a PR?
I could and I was going to, but then I made a last rebase to master and suddenly the errors went away! After more than a month with several rebases. It is a bit annoying. Now I can't help wondering why there is no error when #include <array> is omitted. I'm not going to make a PR now because it doesn't make sense when it works and no one else seems to have had this problem. I wait til it shows again.
Post Reply