r/OpenFOAM • • 1d ago

Help compiling openfoam-com arch linux

[SOLVED] I'm trying to install openfoam-com v2606 from this AUR repository: https://aur.archlinux.org/packages/openfoam-com, but every time it tries to compile OpenFoam I get an error. I've even tried manually downloading/compiling older versions of OpenFoam but they give the exact same error. Here is the error output from the AUR compilation:

g++ -std=c++17 -m64 -pthread -DOPENFOAM=2606 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -Wno-attributes -Wno-unknown-pragmas -O3 -DNoRepository -ftemplate-depth=1000 -I/home/sandwich/.cache/yay/openfoam-com/src/OpenFOAM-v2606/src/finiteVolume/lnInclude -I/home/sandwich/.cache/yay/openfoam-com/src/OpenFOAM-v2606/src/meshTools/lnInclude -I/home/sandwich/.cache/yay/openfoam-com/src/OpenFOAM-v2606/src/transportModels/compressible/lnInclude -I/home/sandwich/.cache/yay/openfoam-com/src/OpenFOAM-v2606/src/thermophysicalModels/basic/lnInclude -I/home/sandwich/.cache/yay/openfoam-com/src/OpenFOAM-v2606/src/thermophysicalModels/specie/lnInclude -I/home/sandwich/.cache/yay/openfoam-com/src/OpenFOAM-v2606/src/thermophysicalModels/solidSpecie/lnInclude -I/home/sandwich/.cache/yay/openfoam-com/src/OpenFOAM-v2606/src/thermophysicalModels/thermophysicalProperties/lnInclude -I/home/sandwich/.cache/yay/openfoam-com/src/OpenFOAM-v2606/src/functionObjects/field/lnInclude -iquote. -IlnInclude -I/home/sandwich/.cache/yay/openfoam-com/src/OpenFOAM-v2606/src/OpenFOAM/lnInclude -I/home/sandwich/.cache/yay/openfoam-com/src/OpenFOAM-v2606/src/OSspecific/POSIX/lnInclude -fPIC -c derivedFvPatchFields/speciesSorption/speciesSorptionFvPatchScalarField.C -o /home/sandwich/.cache/yay/openfoam-com/src/OpenFOAM-v2606/build/linux64GccDPInt32Opt/src/thermophysicalModels/reactionThermo/derivedFvPatchFields/speciesSorption/speciesSorptionFvPatchScalarField.o

chemistryReaders/chemkinReader/chemkinLexer.L:49:38: error: ‘YY_BUF_SIZE’ was not declared in this scope

49 | int Foam::chemkinReader::yyBufSize = YY_BUF_SIZE;

| ^~~~~~~~~~~

chemistryReaders/chemkinReader/chemkinLexer.L:49:38: note: the macro ‘YY_BUF_SIZE’ had not yet been defined

/home/sandwich/.cache/yay/openfoam-com/src/OpenFOAM-v2606/build/linux64GccDPInt32Opt/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinLexer.L.cc:33791:9: note: it was later defined here

33791 | #define YY_BUF_SIZE (2 * YY_READ_BUF_SIZE)

| ^~~~~~~~~~~

make: *** [/home/sandwich/.cache/yay/openfoam-com/src/OpenFOAM-v2606/wmake/rules/General/transform:42: /home/sandwich/.cache/yay/openfoam-com/src/OpenFOAM-v2606/build/linux64GccDPInt32Opt/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinLexer.o] Error 1

make: *** Waiting for unfinished jobs....

I have no idea what is causing this and can't find anyone else with this problem. If anyone has ideas I would be so thankful!!!

1 Upvotes

2 comments sorted by

1

u/JollyInterview9989 1d ago

In this day and age even free LLM like gemini can help than anyone else out there -

"This happens because chemkinLexer.L references YY_BUF_SIZE in its top %{ ... %} block (line 49), while your system's version of flex generates the #define YY_BUF_SIZE macro much further down in chemkinLexer.L.cc (line 33791). That's why older OpenFOAM versions hit the exact same error on your machine—it's a flex code-generation ordering issue rather than a specific OpenFOAM bug.

Quick fix via the AUR PKGBUILD**:**

  1. Go to your yay cache folder: Bashcd ~/.cache/yay/openfoam-com
  2. Open PKGBUILD and add this line inside prepare() (create prepare() if it doesn't exist) to define YY_BUF_SIZE before line 49: Bashsed -i 's/int Foam::chemkinReader::yyBufSize = YY_BUF_SIZE;/#ifndef YY_BUF_SIZE\n#define YY_BUF_SIZE 16384\n#endif\n&/' \ "${srcdir}/OpenFOAM-v${pkgver}/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinLexer.L"
  3. Build and install manually from that folder: Bashmakepkg -si

(Note: If the build complains about YY_BUF_SIZE being redefined later in chemkinLexer.L.cc, move int Foam::chemkinReader::yyBufSize = YY_BUF_SIZE; down to the bottom %% user-code section of chemkinLexer.L instead.)

Just get vs code or antigravity handle it, the free tiers will sort it out before hitting limits

1

u/bananasplits350 1d ago

Thank you. I ended up figuring out the problem before I saw this. I updated my packages with “pacman -Syu”, and the problem went away, so I guess a package was being problematic but got fixed.