Ubuntu 20.04 安装 OpenFOAM-v1712
-
安装老版本的gcc
首先,需要安装老版本的g++/gcc:
sudo gedit /etc/apt/sources.list
添加下面两行:
deb http://mirrors.aliyun.com/ubuntu/ xenial main deb http://mirrors.aliyun.com/ubuntu/ xenial universe
然后:
sudo apt-get update sudo apt-get install g++-5 gcc-5 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 100 sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 100
现在,就应该默认选择gcc-5,g++-5了。接着,顺着编译OpenFOAM-v1712就好。
新版ubuntu适配
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 40976EAF437D05B5 NO_PUBKEY 3B4FE6ACC0B21F32
则需要运行:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 40976EAF437D05B5 sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32
上方代码是后面的两个key
查看已有的版本:
ls /usr/bin/gcc* ls /usr/bin/g++*
选择版本:
sudo update-alternatives --config gcc
安装老版本的gfortran
输入
sudo gedit /etc/apt/sources.list
添加下面两行:
deb http://mirrors.aliyun.com/ubuntu/ trusty main deb-src http://mirrors.aliyun.com/ubuntu/ trusty universe
然后:
sudo apt-get update sudo apt-get install gfortran-4.7 libgfortran-4.7-dev sudo update-alternatives --install /usr/bin/gfortran gfortran /usr/bin/gfortran-4.7 100
-
李老师您好,
我按照您的提示:sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 100
目前默认gcc-5
gcc (Ubuntu 5.3.1-14ubuntu2) 5.3.1 20160413 Copyright (C) 2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
我想切换回g9,用命令
sudo update-alternatives --config gcc
得到:
There is only one alternative in link group gcc (providing /usr/bin/gcc): /usr/bin/gcc-5 Nothing to configure.
没有切换提示,咋办?
我用命令
ls /usr/bin/gcc*
/usr/bin/gcc /usr/bin/gcc-ar /usr/bin/gcc-nm /usr/bin/gcc-ranlib /usr/bin/gcc-5 /usr/bin/gcc-ar-5 /usr/bin/gcc-nm-5 /usr/bin/gcc-ranlib-5 /usr/bin/gcc-9 /usr/bin/gcc-ar-9 /usr/bin/gcc-nm-9 /usr/bin/gcc-ranlib-9
应该是g9也在的,不知道为啥不能切换,跟百度不一样
-
@chengan-wang 我有时候也遇到过这个问题 来回操作几次就解决了 目前不知道原因 不过还可以不算麻烦
-
@chengan-wang 2.4版本需要安装gcc/g++-4.8 你试试
-
@chengan-wang 你用的低版本g++么,我装的更低版本的openfoam-2.1都没问题呢
-
@chengan-wang log提示什么错误
-
@李东岳 李老师,编译过程出现了很多错误:
== Generating build files == Configuring libCGAL -- Requested component: MPFR -- Requested component: GMP libCGAL is configured -- Sources for CGAL component library 'CGAL_Core/CMakeLists.txt' detected CMake Error at src/CMakeLists.txt:81 (add_subdirectory): add_subdirectory given source "/home/chengan/OpenFOAM/ThirdParty-2.4.0/CGAL-4.6/src/CGAL_Core/CMakeLists.txt" which is not an existing directory. Call Stack (most recent call first): src/CMakeLists.txt:140 (configure_component) -- Sources for CGAL component library 'CGAL_ImageIO/CMakeLists.txt' detected CMake Error at src/CMakeLists.txt:81 (add_subdirectory): add_subdirectory given source "/home/chengan/OpenFOAM/ThirdParty-2.4.0/CGAL-4.6/src/CGAL_ImageIO/CMakeLists.txt" which is not an existing directory. Call Stack (most recent call first): src/CMakeLists.txt:140 (configure_component) -- Sources for CGAL component library 'CGAL_Qt3/CMakeLists.txt' detected CMake Error at src/CMakeLists.txt:81 (add_subdirectory): add_subdirectory given source "/home/chengan/OpenFOAM/ThirdParty-2.4.0/CGAL-4.6/src/CGAL_Qt3/CMakeLists.txt" which is not an existing directory. Call Stack (most recent call first): src/CMakeLists.txt:140 (configure_component) -- Sources for CGAL component library 'CGAL_Qt4/CMakeLists.txt' detected CMake Error at src/CMakeLists.txt:81 (add_subdirectory): add_subdirectory given source "/home/chengan/OpenFOAM/ThirdParty-2.4.0/CGAL-4.6/src/CGAL_Qt4/CMakeLists.txt" which is not an existing directory. Call Stack (most recent call first): src/CMakeLists.txt:140 (configure_component) -- Sources for CGAL component libraries 'CGAL_Core/CMakeLists.txt;CGAL_ImageIO/CMakeLists.txt;CGAL_Qt3/CMakeLists.txt;CGAL_Qt4/CMakeLists.txt' detected == Generating build files (DONE) == -- Configuring incomplete, errors occurred! See also "/home/chengan/OpenFOAM/ThirdParty-2.4.0/build/linux64Gcc/CGAL-4.6/CMakeFiles/CMakeOutput.log". See also "/home/chengan/OpenFOAM/ThirdParty-2.4.0/build/linux64Gcc/CGAL-4.6/CMakeFiles/CMakeError.log". + exit 1
还有很多这样的:
/usr/bin/ld: /home/chengan/OpenFOAM/OpenFOAM-2.4.0/platforms/linux64GccDPOpt/lib/libtriSurface.so: undefined reference to `yyFlexLexer::yywrap()' collect2: error: ld returned 1 exit status make[2]: *** [/home/chengan/OpenFOAM/OpenFOAM-2.4.0/wmake/Makefile:150: /home/chengan/OpenFOAM/OpenFOAM-2.4.0/platforms/linux64GccDPOpt/bin/interMixingFoam] Error 1 make[1]: *** [/home/chengan/OpenFOAM/OpenFOAM-2.4.0/wmake/MakefileApps:39: interFoam] Error 2 make[1]: Target 'application' not remade because of errors. make: *** [/home/chengan/OpenFOAM/OpenFOAM-2.4.0/wmake/MakefileApps:39: multiphase] Error 2 make: Target 'application' not remade because of errors.
log文件如下:
log.tar.xz
希望李老师能百忙之中指点一下! -
-
@李东岳 谢谢李老师,不过命令报错了
chengan@chengan-MS-7C80:~/OpenFOAM/OpenFOAM-2.4.0$ find src applications -name "*.L" -type f | xargs sed -i -e 's=(YY_FLEX_SUBMINOR_VERSION)=YY_FLEX_MINOR_VERSION < 6 && \1=' sed: -e expression #1, char 61: invalid reference \1 on `s' command's RHS
-
-
@chengan-wang 没关系,主要是其中做foamQuad网格的,这个用得少
-
@chengan-wang 为什么要用openfoam2.4.?
-
-