Because gcc 7.0 no longer support in ubuntu 22.04 or higher so that the installing of Foamextend 4.1 faces trouble.

https://openfoamwiki.net/index.php/Installation/Linux/foam-extend-4.1/Ubuntu04

So in this blog post I will try to give full commands to install foamextend4.1 in Ubutu22.04. Lets run the following:

  • Clone foamextend4.
cd ~
mkdir foam
cd foam
git clone git://git.code.sf.net/p/foam-extend/foam-extend-4.1 foam-extend-4.1

  • Set environment variables
cd ~/foam/foam-extend-4.1
source etc/bashrc
 
echo "alias fe41='source \$HOME/foam/foam-extend-4.1/etc/bashrc'" >> $HOME/.bashrc
  • Add the the command in file “/etc/apt/source.list” so that os can access the gcc-7, g++ 7 and gfortran -7.

deb [arch=amd64] http://archive.ubuntu.com/ubuntu focal main universe

  • Update system again

sudo apt update

  • The same commands as in the official tutorial website:
sudo apt-get install git-core build-essential binutils-dev cmake flex \
zlib1g-dev libncurses5-dev curl bison \
libxt-dev rpm mercurial graphviz python python-dev gcc-7 g++-7
  • Make sure the system will use gcc 7 instead of default gcc (which is gcc 11) by:

sudo update-alternatives –install /usr/bin/gcc gcc /usr/bin/gcc-7 7

sudo update-alternatives –install /usr/bin/g++ g++ /usr/bin/g++-7 7

sudo update-alternatives –install /usr/bin/gfortran gfortran /usr/bin/gfortran-7 7

  • The next command:
cd ~/foam/foam-extend-4.1
 
echo "export WM_CC='gcc-7'" >> etc/prefs.sh
echo "export WM_CXX='g++-7'" >> etc/prefs.sh

source etc/bashrc

sed -i -e 's=rpmbuild --define=rpmbuild --define "_build_id_links none" --define=' ThirdParty/tools/makeThirdPartyFunctionsForRPM
sed -i -e 's/gcc/\$(WM_CC)/' wmake/rules/linux64Gcc/c
sed -i -e 's/g++/\$(WM_CXX)/' wmake/rules/linux64Gcc/c++
  • Now
./Allwmake.firstInstall

Hope this help and please leave comments so that I can help you more!

Leave a comment

I’m Anh Van

Thank you for visiting my blog.

My idea is to create a space where I can share my experiences from my PhD journey in Mechanical Engineering at NYU. I focus on computational fluid dynamics and microchip fabrication for biological application.

Let’s connect