Menu

#68 Compiling FOAM-Extend with GCC 11

1.0
open
nobody
None
2022-02-11
2021-10-07
No

I'm using OpenFOAM-Extend-4.1-20201102-11cb6d.tar.gz.

Compiling FOAM-Extend with GCC 11 resulted in a bunch of errors.

  In file included from primitives/Lists/PackedBoolList.C:26:
  primitives/Lists/PackedBoolList.H: At global scope:
  primitives/Lists/PackedBoolList.H:122:46: error: class Foam::UList<unsigned int> Foam::UList<unsigned int>::UList is private within this context
    122 |         explicit inline PackedBoolList(const UList<label>& indices);
        |                                              ^~~~~~~~~~~~
  In file included from primitives/Lists/PackedBoolList.H:46,
                   from primitives/Lists/PackedBoolList.C:26:
  lnInclude/PackedList.H:147:7: note: declared private here
    147 | class PackedList
        |       ^~~~~~~~~~
  In file included from primitives/Lists/PackedBoolList.C:26:

May I ask you for help?

Best regards,
Robert

Related

Tickets: #68

Discussion

  • Hrvoje Jasak

    Hrvoje Jasak - 2021-10-07

    Hi,

    I think I fixed all of this, around 15/Sep. I assume you are using the master branch. Can you please re-pull and check.

    I am no Ubuntu-20.04

    gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04)

    and it compiles without errors.

    Please let me know,

    Hrv

     
    • Robert Mijakovic

      Hi Hrvoje,

      I will explain it in more details.
      I was building FOAM-Extend 4.1 from the master branch, commit 11cb6dafc53a5d3ce3292dc3135bfc0f7378907e – November 2nd 2020; with GCC 10.2, 10.3 and 11.2.
      The first two compilers compiled just fine, and the last one, 11.2, fails with the error below.

      You suggested to pull the latest changes from the master branch, however, the last commit to the master branch is from July 7th, 2021, thus it doesn’t contain the fix.
      The changes from September 15th belong to the nextRelease branch, thus, I used the tip of that branch, commit ff9c6040d5b1cd65f31e0b3b8776b6f5b3a38144 – September 27th 2021.

      While compiling the suggested release with GCC 11.2, I get exactly the same errors like with the commit 11cb6d.

      Commands executed to clone the repository and checkout the commit:

      $ git clone https://git.code.sf.net/p/foam-extend/foam-extend-4.1.git
      $ git checkout ff9c60

      GCC version:
      $ gcc --version
      gcc (GCC) 11.2.0

      CentOS release:
      $ rpm -q centos-linux-release
      centos-linux-release-8.4-1.2105.el8.noarch

      If necessary, I can provide the complete build log with all the commads being executed.

      Best regards/Lijepi pozdrav,
      Robert

      Dr. rer. nat. Robert Mijaković | HPC System Software Architect

      LuxProvide
      3, Op der Poukewiss | L-7795 Bissen
      Grand-Duchy of Luxembourg
      M (+352) 691 396 474
      robert.mijakovic@lxp.lurobert.mijakovic@lxp.lu | www.luxprovide.luhttp://www.luxprovide.lu/

      From: Hrvoje Jasak hjasak@users.sourceforge.nethjasak@users.sourceforge.net
      Sent: Thursday, 7 October 2021 16:35
      To: [foam-extend:tickets] 68@tickets.foam-extend.p.re.sourceforge.net68@tickets.foam-extend.p.re.sourceforge.net
      Subject: [foam-extend:tickets] #68 Compiling FOAM-Extend with GCC 11

      Hi,

      I think I fixed all of this, around 15/Sep. I assume you are using the master branch. Can you please re-pull and check.

      I am no Ubuntu-20.04

      gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04)

      and it compiles without errors.

      Please let me know,

      Hrv


      [tickets:#68]https://sourceforge.net/p/foam-extend/tickets/68/ Compiling FOAM-Extend with GCC 11

      Status: open
      Milestone: 1.0
      Created: Thu Oct 07, 2021 02:13 PM UTC by Robert Mijakovic
      Last Updated: Thu Oct 07, 2021 02:13 PM UTC
      Owner: nobody

      I'm using OpenFOAM-Extend-4.1-20201102-11cb6d.tar.gz.

      Compiling FOAM-Extend with GCC 11 resulted in a bunch of errors.

      In file included from primitives/Lists/PackedBoolList.C:26:

      primitives/Lists/PackedBoolList.H: At global scope:

      primitives/Lists/PackedBoolList.H:122:46: error: class Foam::UList<unsigned int=""> Foam::UList<unsigned int="">::UList is private within this context</unsigned></unsigned>

      122 |         explicit inline PackedBoolList(const UList<label>& indices);
      
          |                                              ^~~~~~~~~~~~
      

      In file included from primitives/Lists/PackedBoolList.H:46,

                     from primitives/Lists/PackedBoolList.C:26:
      

      lnInclude/PackedList.H:147:7: note: declared private here

      147 | class PackedList
      
          |       ^~~~~~~~~~
      

      In file included from primitives/Lists/PackedBoolList.C:26:

      May I ask you for help?

      Best regards,
      Robert


      Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/foam-extend/tickets/68/

      To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/

       

      Related

      Tickets: #68

  • Robert Mijakovic

    Hi Hrvoje,

    I will explain it in more details.
    I was building FOAM-Extend 4.1 from the master branch, commit 11cb6dafc53a5d3ce3292dc3135bfc0f7378907e – November 2nd 2020; with GCC 10.2, 10.3 and 11.2.
    The first two compilers compiled just fine, and the last one, 11.2, fails with the error below.

    You suggested to pull the latest changes from the master branch, however, the last commit to the master branch is from July 7th, 2021, thus it doesn’t contain the fix.
    The changes from September 15th belong to the nextRelease branch, thus, I used the tip of that branch, commit ff9c6040d5b1cd65f31e0b3b8776b6f5b3a38144 – September 27th 2021.

    While compiling the suggested release with GCC 11.2, I get exactly the same errors like with the commit 11cb6d.

    Commands executed to clone the repository and checkout the commit:

    $ git clone https://git.code.sf.net/p/foam-extend/foam-extend-4.1.git
    $ git checkout ff9c60
    

    GCC version:

    $ gcc --version
    gcc (GCC) 11.2.0
    

    CentOS release:

    $ rpm -q centos-linux-release
    centos-linux-release-8.4-1.2105.el8.noarch
    

    If necessary, I can provide the complete build log with all the commads being executed.

    Best regards/Lijepi pozdrav,
    Robert

     
  • Robert Mijakovic

    Hi guys,

    any news on this ticket?
    How can I help so that we make it work?

    Best regards,
    Robert

     
  • Robert Mijakovic

    Hi guys,

    GCC 11 switched the default mode for C++ to -std=gnu++17 instead of -std=gnu++14.
    The problem is that GCC 11 FOAM-Extend code is not in accordance with C++17 standard.
    The code compiled fine when I switched GCC 11 back to -std=c++14, 2014 ISO C++ standard plus amendments.

    Best regards,
    Robert

     
  • Christoph

    Christoph - 2021-11-19

    Hi,
    I have the same problem. Would you please elaborate on how to approach this problem. Where do I switch the -std flag?

    Best regards,
    Christoph

     
  • Hrvoje Jasak

    Hrvoje Jasak - 2021-11-22

    Hi,

    You can switch the flag in

    linux64Gcc/c++

    (or equivalent) in

    foam-extend-5.0/wmake/rules

    I have now compiled everything using c++-17 and there was only one fix in NamedEnum. The rest compiles fine. If you wish to use this, please check out the nextRelease branch, as follows:

    git clone -b nextRelease <blah blah=""> foam-extend-5.0</blah>

    and compile. Most porting changes are in the nextRelease branch, as we are due for foam-extend-5.0 anyway.

    Hope this helps,
    
    Hrvoje
    
     
  • Christoph

    Christoph - 2021-11-23

    Hi,

    thank you for you help!

    I now tried as you suggested and pulled the nextRelease branch and tried to compile. I still get the same errors, such as:

    SOURCE=motionDiffusivity/inverseDistance/inverseDistanceDiffusivity.C ;  g++ -std=c++14 -m64 -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3  -DNoRepository -ftemplate-depth-200 -I/opt/OpenFoam/foam-extend-5.0/src/postProcessing/functionObjects/forces/lnInclude     -I/opt/OpenFoam/foam-extend-5.0/src/meshTools/lnInclude     -I/opt/OpenFoam/foam-extend-5.0/src/dynamicMesh/dynamicMesh/lnInclude     -I/opt/OpenFoam/foam-extend-5.0/src/finiteVolume/lnInclude -IlnInclude -I. -I/opt/OpenFoam/foam-extend-5.0/src/foam/lnInclude -I/opt/OpenFoam/foam-extend-5.0/src/OSspecific/POSIX/lnInclude   -fPIC -c $SOURCE -o Make/linux64GccDPInt32Opt/inverseDistanceDiffusivity.o
    In file included from /opt/OpenFoam/foam-extend-5.0/src/foam/lnInclude/ZoneMesh.H:42,
                     from /opt/OpenFoam/foam-extend-5.0/src/foam/lnInclude/pointZoneMesh.H:32,
                     from /opt/OpenFoam/foam-extend-5.0/src/foam/lnInclude/polyMesh.H:54,
                     from /opt/OpenFoam/foam-extend-5.0/src/foam/lnInclude/pointMesh.H:37,
                     from /opt/OpenFoam/foam-extend-5.0/src/foam/lnInclude/pointPatchField.H:44,
                     from /opt/OpenFoam/foam-extend-5.0/src/foam/lnInclude/fixedValuePointPatchFields.H:37,
                     from lnInclude/fvMotionSolverTemplates.C:27,
                     from lnInclude/fvMotionSolver.H:127,
                     from lnInclude/motionDiffusivity.H:38,
                     from motionDiffusivity/uniform/uniformDiffusivity.H:38,
                     from motionDiffusivity/uniform/uniformDiffusivity.C:26:
    /opt/OpenFoam/foam-extend-5.0/src/foam/lnInclude/PackedBoolList.H:122:46: error: class Foam::UList<unsigned int> Foam::UList<unsigned int>::UList is private within this context
      122 |         explicit inline PackedBoolList(const UList<label>& indices);
          |                                              ^~~~~~~~~~~~
    In file included from /opt/OpenFoam/foam-extend-5.0/src/foam/lnInclude/PackedBoolList.H:46,
                     from /opt/OpenFoam/foam-extend-5.0/src/foam/lnInclude/ZoneMesh.H:42,
                     from /opt/OpenFoam/foam-extend-5.0/src/foam/lnInclude/pointZoneMesh.H:32,
                     from /opt/OpenFoam/foam-extend-5.0/src/foam/lnInclude/polyMesh.H:54,
                     from /opt/OpenFoam/foam-extend-5.0/src/foam/lnInclude/pointMesh.H:37,
                     from /opt/OpenFoam/foam-extend-5.0/src/foam/lnInclude/pointPatchField.H:44,
                     from /opt/OpenFoam/foam-extend-5.0/src/foam/lnInclude/fixedValuePointPatchFields.H:37,
                     from lnInclude/fvMotionSolverTemplates.C:27,
                     from lnInclude/fvMotionSolver.H:127,
                     from lnInclude/motionDiffusivity.H:38,
                     from motionDiffusivity/uniform/uniformDiffusivity.H:38,
                     from motionDiffusivity/uniform/uniformDiffusivity.C:26:
    /opt/OpenFoam/foam-extend-5.0/src/foam/lnInclude/PackedList.H:147:7: note: declared private here
      147 | class PackedList
          |       ^~~~~~~~~~
    

    Throughout the compilation.

    I tried to modify the CC flag in the rules/linux64Gcc/c++ file yet that did not solve anything.

    Any other idea what I am doing wrong?

    Thank you!

     
  • Hrvoje Jasak

    Hrvoje Jasak - 2021-11-23

    This is bizarre. I am on gcc-9.3.0 and there isn't a problem. I think it will be because of unsigned ints. I don't want to change a compiler, and this is not related to c++-17 (I tried).

    What you can do is to take this constructor from label - there are 2:

        //- Construct from a list of labels
        //  using the labels as indices to indicate which bits are set
        explicit inline PackedBoolList(const UList<label>& indices);
    
        //- Construct from a list of labels
        //  using the labels as indices to indicate which bits are set
        explicit inline PackedBoolList(const UIndirectList<label>& indices);
    

    and add 2 more, which instead of label use unsigned int, eg:

        //  using the labels as indices to indicate which bits are set
        explicit inline PackedBoolList(const UList<unsigned int>& indices);
    

    using a cast in the implementation code. I had to change one like that in NamedEnum.

    Hope this helps; if there are more of them, they will be all the same. Is there anything in the compiler release notes about unsigned?

    Hrv

     
  • Christoph

    Christoph - 2021-11-23

    I added the two constructors and had to add some others witht he same error.
    I got than an error regarding the typedef

    In file included from /opt/OpenFoam/foam-extend-5.0/src/foam/lnInclude/Pstream.H:43,
                     from fileMonitor.C:28:
    /opt/OpenFoam/foam-extend-5.0/src/foam/lnInclude/labelList.H:46:31: error: conflicting declaration typedef class Foam::UList<unsigned int> Foam::unallocLabelList
       46 |   typedef UList<unsigned int> unallocLabelList;
          |                               ^~~~~~~~~~~~~~~~
    In file included from /opt/OpenFoam/foam-extend-5.0/src/foam/lnInclude/HashTable.C:30,
                     from /opt/OpenFoam/foam-extend-5.0/src/foam/lnInclude/HashTable.H:557,
                     from /opt/OpenFoam/foam-extend-5.0/src/foam/lnInclude/NamedEnum.H:38,
                     from fileMonitor.H:46,
                     from fileMonitor.C:26:
    /opt/OpenFoam/foam-extend-5.0/src/foam/lnInclude/List.H:71:22: note: previous declaration as typedef class Foam::UList<int> Foam::unallocLabelList
       71 | typedef UList<label> unallocLabelList;
    

    I tried to fix that by modifying the following:

      //typedef UList<unsigned int> unallocLabelList;
      typedef UList<unsigned int> unsignedlabelList;
    

    Still the error arises as:

    SOURCE=db/IOstreams/Pstreams/IPstream.C ;  g++ -std=c++11 -m64 -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3  -DNoRepository -ftemplate-depth-200 -DOMPI_SKIP_MPICXX -I/usr/local/include -pthread     -I/opt/OpenFoam/foam-extend-5.0/ThirdParty/zlib-1.2.3 -IlnInclude -I. -I/opt/OpenFoam/foam-extend-5.0/src/foam/lnInclude -I/opt/OpenFoam/foam-extend-5.0/src/OSspecific/POSIX/lnInclude   -fPIC -c $SOURCE -o Make/linux64GccDPInt32Opt/IPstream.o
    In file included from primitives/Lists/PackedBoolList.C:26:
    primitives/Lists/PackedBoolList.H:122:46: error: class Foam::UList<unsigned int> Foam::UList<unsigned int>::UList is private within this context
      122 |         explicit inline PackedBoolList(const UList<unsigned int>& indices);
          |                                              ^~~~~~~~~~~~~~~~~~~
    In file included from primitives/Lists/PackedBoolList.H:46,
                     from primitives/Lists/PackedBoolList.C:26:
    lnInclude/PackedList.H:147:7: note: declared private here
      147 | class PackedList
          |       ^~~~~~~~~~
    

    Sorry I am not very advanced in c++ so I am a bit lost here.

     
  • Christoph

    Christoph - 2021-11-23

    I looked now (as the error message suggests) into the PackedList.H and by switching the base class (private List unsigned int ) from private to public (public List unsigned int ) the error seems to vanish.

     

    Last edit: Christoph 2021-11-23
  • Etienne Lorriaux

    Hello,

    same story here, using gcc 11.2.0 on gentoo system with a fresh clone of nextRelease branch.

    It does not compile , even with -std=c++14 instruction, I had to use the trick provided by Christoph to get it compiled.

     

Log in to post a comment.