CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Running, Solving & CFD (
-   -   Linking new class to solver (

hartinger April 25, 2005 06:02

Hello, I would like write m

I would like write my own class to extend icoFoam.
The class is defined in deflection.H and deflection.C, which are in the same directory as the solver. I included deflection.C in Make/files.
That works fines and everything compiles as long as I dont want to call any member functions of that class. If i call one of them it returns
> In function 'main':
> :undefined reference to 'main::deflection::test()'

I assume, I need to inclucde some command in Make/options, but I couldn't figure out which one.

thank you

hartinger April 25, 2005 06:17

Hi again, reading the forum
Hi again,

reading the forum helps. See the "namespace" thread.
I was putting the #include "deflection.H" into the main function, which i shouldn't do apparently, dunno why, though.

Sorry for this self-conversation

henry April 25, 2005 06:25

deflection.H contains declarat
deflection.H contains declarations and deflection.C contains definitions which you compile outside the scope of main. Then you wish to use the classes/functions from within main but you need to tell the compiler that they are declared in a different scope which is done my including deflection.H in the file containing the main function but not inside the main function because that would change the scope of the classes/functions and hence give you the linkage error you had before.

hartinger April 25, 2005 06:36

thank you, i didn't think abou
thank you, i didn't think about the scope

All times are GMT -4. The time now is 19:24.