编译自己的求解器遇到问题“undefined reference”
-
我在想是不是 我的这个option里买有格式错误。
我试过将EXE_LIBS = \ -L$(FOAM_USER_LIBBIN)\ -lnetPanel \
改为
EXE_LIBS = \ -L$(FOAM_USER_LIBBIN) -lnetPanel \
结果感觉更错啦
-lm -o /home/hui/OpenFOAM/hui-v1906/platforms/linux64GccDPInt32Opt/bin/dynaPorousNetFoam /usr/bin/ld: cannot find -lnetPanel collect2: error: ld returned 1 exit status /opt/OpenFOAM/OpenFOAM-v1906/wmake/makefiles/general:140: recipe for target '/home/hui/OpenFOAM/hui-v1906/platforms/linux64GccDPInt32Opt/bin/dynaPorousNetFoam' failed make: *** [/home/hui/OpenFOAM/hui-v1906/platforms/linux64GccDPInt32Opt/bin/dynaPorousNetFoam] Error 1
-
@wwzhao 赵教授,这两个函数我记得定义了,
// Constructors netPanel ( const dictionary& netDict ); //- Destructor ~netPanel();
但是我有一点不太明白,为什么有的函数后面有一个const,有的没有。例如:
这个虚函数是void funname() const;void addResistance ( fvVectorMatrix& UEqn, const volScalarField& nu, const fvMesh& mesh, const matrix& structuralPositions, const matrix& structuralElements )const;
而这个函数是 bool funname(); 就没有const了。
bool isInPorousZone ( const point x, const volVectorField& structuralPositions, const vector& structuralElementi );
const 在括号里面我知道是可以保证传入的参数不变,但是在外边是啥意思啊?
-
@wwzhao
定义也是有的。如下Foam::netPanel::netPanel ( const dictionary& netDict ) : // initial components netDict_(netDict), porousPropertiesDict_(netDict_.subDict("porousProperties")), porosity_(readScalar(porousPropertiesDict_.lookup("porosity"))), thickness_(readScalar(porousPropertiesDict_.lookup("halfthickness"))) // D_(readVector(porousPropertiesDict_.lookup("D"))), // initial as zeros // F_(readVector(porousPropertiesDict_.lookup("D"))) // initial as zeros { dimensionedVector D_(porousPropertiesDict_.lookup("D")); dimensionedVector F_(porousPropertiesDict_.lookup("F")); }
-
@huiCfd 把 netPanel.so 重命名成 libnetPanel.so 试试呢?
-
@wwzhao 是的,去掉何不去掉都试过了,
去掉后显示的错误是-lm -o /home/hui/OpenFOAM/hui-v1906/platforms/linux64GccDPInt32Opt/bin/dynaPorousNetFoam /usr/bin/ld: cannot find -llibnetPanel collect2: error: ld returned 1 exit status /opt/OpenFOAM/OpenFOAM-v1906/wmake/makefiles/general:140: recipe for target '/home/hui/OpenFOAM/hui-v1906/platforms/linux64GccDPInt32Opt/bin/dynaPorousNetFoam' failed make: *** [/home/hui/OpenFOAM/hui-v1906/platforms/linux64GccDPInt32Opt/bin/dynaPorousNetFoam] Error 1
没去掉的话跟原来的错误一样,都是undefined reference
-
@huiCfd
1、去掉$(FOAM_USER_LIBBIN)后的换行符,注意后面的 netPanel 前不要加libEXE_LIBS = \ -L$(FOAM_USER_LIBBIN) -lnetPanel \
2、编译出来的 netPanel.so 文件重命名为 libnetPanel.so