OpenFOAM 编译报错集锦
[ZYsprayFoam]$ wmake |
solution:先执行 wclean 再进行 wmake
‘fvc’ has not been declared |
solution:#include "fvc.H"
mkdir: cannot create directory ‘’: No such file or directory |
这是因为 Make/files 里边输出路径的变量没有定义
比如:
LIB = $(FOAM_USER_LIBBIN_DEV)/libZYcombustionModels |
solution:
export FOAM_USER_LIBBIN_DEV=/<path>/platforms/$WM_OPTIONS/lib |
YEEqn.H:86:6: error: |
下边这个 T 是一个 const 引用,但我这里要给它赋值,所以报错。
solution:thermo 库有两个版本的 T(),使用非 const 那个即可,即在 solver 中定义 T 时,使用 volScalarField& T = thermo.T();
YEEqn.H:85:61: error: |
这里 radiation 是一个 autoPtr,而我要把它转换类型它的派生类。
solution:在 radiation 后边加一个 () 即可。autoPtr 加括号返回正常的指针。
undefined reference to 'Foam::functionName()' |
库中函数只申明,没有定义,就会出现这个错误。
YEqn.H(30): error: no operator "*" matches these operands |
这里的 R(Yi) 是 tmp,fvMatrix,scalar,,,不能和 volScalarField(或者 scalar) 相乘。
solution:很简单,scalar 放前边就行了。。。即:efficiency_/TF_*reaction->R(Yi)。因为 scalar*fvMatrix 是允许的!!!
lnInclude/TDACCCMChemistryModel.C(709): error #308: member |
因为 timeSteps_ 是基类中的 private 变量,而私有变量只能基类自己内部使用。
solution:我是这样做的:在基类中,将这个变量从 private 改成 protected。
WMspray/WMspray.C(299): error: dynamic_cast cannot cast away const |
代码改为以下即可,因为 lookupObject 得到的对象是 const。lookupObjectRef 得到的才是可以修改的。
basicSprayCloud& spray_ = dynamic_cast< basicSprayCloud&>(this->mesh() |
~/OpenFOAM/OpenFOAM-2.3.x/src/finiteVolume/lnInclude/cyclicAMIFvPatch.H(39): |
这是因为旧版本的代码在 OF23x 中编译,解决方法是在 EXE_INC 中加入 -I$(LIB_SRC)/meshTools/lnInclude。
Post.C(70): error: name followed by "::" must be a class or namespace name |
这是因为没有 include 双冒号后边类的头文件。
findMax.C(212): error: ABC is not a template |
需要 include ABC 的头文件,如果已经 include 了它的头文件,依然出现这个错误。那么检查 ABC 是否处于另一个命名空间里边。
findMax.C(235): error: the operand of a runtime dynamic_cast must have a |
可能是因为 objectName 是 autoPtr,需要在它后边加 ()。

