r/OpenFOAM • u/bananasplits350 • 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
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.LreferencesYY_BUF_SIZEin its top%{ ... %}block (line 49), while your system's version offlexgenerates the#define YY_BUF_SIZEmacro much further down inchemkinLexer.L.cc(line 33791). That's why older OpenFOAM versions hit the exact same error on your machine—it's aflexcode-generation ordering issue rather than a specific OpenFOAM bug.Quick fix via the AUR
PKGBUILD**:**yaycache folder: Bashcd ~/.cache/yay/openfoam-comPKGBUILDand add this line insideprepare()(createprepare()if it doesn't exist) to defineYY_BUF_SIZEbefore 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"(Note: If the build complains about
YY_BUF_SIZEbeing redefined later inchemkinLexer.L.cc, moveint Foam::chemkinReader::yyBufSize = YY_BUF_SIZE;down to the bottom%%user-code section ofchemkinLexer.Linstead.)Just get vs code or antigravity handle it, the free tiers will sort it out before hitting limits