CFD | OpenFOAM | gcc : error: unrecognized command line option ‘--showme:link’; did you mean ‘--force-link’?
Error
Error 1
- gcc: error: unrecognized command line option ‘--showme:link’; did you mean ‘--force-link’?
The error message you are seeing, gcc: error: unrecognized command line option ‘--showme:link’; did you mean ‘--force-link’?, indicates that the GCC compiler does not have an option with that specific name.
vim OpenFOAM-13/etc/bashrc
export WM_MPLIB=INTELMPI #SYSTEMOPENMPI
Error 2
- /usr/bin/ld: cannot find -lmpi
gcc -m64 -fPIC -m64 ... /openfoam13/ThirdParty-13/Zoltan-3.90/build/src -lzoltan -lmpi -lm
- under
mpi/intel64/lib/releasepath - set
export LIBRARY_PATH=$LIBRARY_PATH:/home/wpsze/intel/oneapi/mpi/2021.9.0/lib/release
Error 3
- /bin/sh: flex: command not found
- gcc: error: lex.yy.c: No such file or directory
The error message "flex: command not found" indicates that the flex program is not installed on your system or is not in your shell's search path. flex (Fast Lexical Analyzer) is a tool commonly used during the compilation of other software, such as the Linux kernel, to generate lexical analyzers.
conda install conda-forge::flex- For source env,
- source intel first, and then conda env
source /home/wpsze/intel/oneapi/setvars.sh intel64source /home/wpsze/micromamba/bin/activate cfd_env
- source intel first, and then conda env
Error 4
undefined reference to '__gmpq_init' / '__gmpq_set'/ '__gmpn_copyi'1858 collect2: error: ld returned 1 exit status 1859 make[2]: *** [/home/wpsze/openfoam/OpenFOAM-v2412/OpenFOAM-v2412/wmake/makefiles/general:174: /home/wpsze/openfoam/OpenFOAM-v2412/OpenFOAM-v2412/platforms/linux64GccDP Int32Opt/bin/surfaceBooleanFeatures] Error 1 1860 make[1]: *** [/home/wpsze/openfoam/OpenFOAM-v2412/OpenFOAM-v2412/wmake/makefiles/apps:28: surfaceBooleanFeatures] Error 2 1861 make: *** [/home/wpsze/openfoam/OpenFOAM-v2412/OpenFOAM-v2412/wmake/makefiles/apps:28: surface] Error 2 1862 make: *** Waiting for unfinished jobs....The error "undefined reference to __gmpq_init'" is a linker error in a C/C++ OpenFOAM project, indicating that the linker cannot find the implementation of the
__gmpq_initfunction. This function belongs to the GNU Multiple Precision Arithmetic Library (GMP), which is often used as a dependency for other libraries like CGAL (CGAL(Computational Geometry Algorithms Library)是一個開源的 C++ 程式庫,提供高效且可靠的計算幾何演算法,涵蓋了多邊形、凸包、三角剖分、網格生成等各種幾何資料結構與演算法,廣泛應用於電腦輔助設計、地理資訊系統、電腦圖形、醫學影像、機器人學等領域,並採用雙授權模式 (LGPL/GPL 適用開源,商用需付費)。).
disucss
- ThirdParty clang without gmp/mpfr
- If using ThirdParty
clangwithoutgmp/mpfr, the ThirdPartymakeCGALscript will need to be run manually and specify that there is nogmp/mpfr. - Subequent compilation with
Allwmakewill now run largely without any problems, except that the components linking againstCGAL(foamyMesh and surfaceBooleanFeatures) will also try to link against a nonexistentmpfrlibrary. As a workaround, the link-dependency will be removed inwmake/rules/General/cgalby specifying theCGAL_FLAVOURwhen compiling:no-cgal | cgal-header | cgal-header-no-mpfr | cgal-no-mpfr | cgal-mpfr
- A robuster solution is still being sought.
- If using ThirdParty
Common Solutions
- Explicitly link the library: Ensure that your project's
Make/optionsfile (if you are compiling within OpenFOAM's wmake environment) or your compiler command includes the linker flag for GMP.- Add
-lgmpto the linker flags (e.g.,LIBSvariable in theoptionsfile). The order matters, and dependent libraries should typically appear after the libraries that use them in the linker command. - e.g.
OpenFOAM-v2412/wmake/makefiles/generalEXE_LIBS = -lgmp, seems not works.
- Add
- Verify the library path: If GMP is installed in a non-standard location (e.g., in the OpenFOAM ThirdParty directory or a custom path), you need to specify the library directory using the
-Lflag and the include directory using the-Iflag in yourMake/optionsfile.LDFLAGS = -L$(GMP_LIB_PATH)LIBS = -lgmp ...
- Check compatibility: Ensure that the architecture (32-bit vs. 64-bit) of your compiled code matches that of the GMP library you are linking against.
- Clean and rebuild: After making changes to your installation or
optionsfiles, perform a clean build to ensure all object files and dependencies are correctly re-linked. Usewcleanwithin your OpenFOAM project directory before runningwmakeagain.