CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Programming & Development

undefined reference when adding new member function

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   May 17, 2011, 11:08
Unhappy undefined reference when adding new member function
  #1
Member
 
Florian Ettner
Join Date: Mar 2009
Location: Munich, Germany
Posts: 40
Rep Power: 8
dohnie is on a distinguished road
Hello,
this has cost me six hours so far:

I want to add a new member function to the hCombustionThermo class. I've boiled it down to the simplest possbile problem. In hCombustionThermo.H I write:
Code:
  void hello();
It compiles fine.

In my solver (based on reactingFoam) I write:
Code:
Info<< nl << "Reading thermophysicalProperties" << endl;
autoPtr<hPsiChemistryModel> pChemistry
(
    hPsiChemistryModel::New(mesh)
);
hPsiChemistryModel& chemistry = pChemistry();
hCombustionThermo& thermo = chemistry.thermo();

thermo.hello();     // the only change
It seems that compiling works, but during the linking process an error occurs:

Code:
g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -O3  -DNoRepository -ftemplate-depth-40 -I/nfs/opt/OpenFOAM/OpenFOAM-1.7.1/src/finiteVolume/lnInclude     -I/nfs/opt/OpenFOAM/OpenFOAM-1.7.1/src/turbulenceModels/compressible/turbulenceModel     -I/nfs/opt/OpenFOAM/OpenFOAM-1.7.1/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions     -I/nfs/opt/OpenFOAM/OpenFOAM-1.7.1/src/turbulenceModels/compressible/RAS/lnInclude     -I/nfs/home/ettner/OpenFOAM/ettner-1.7.1/src/thermophysicalModels/reactionThermo/lnInclude     -I/nfs/home/ettner/OpenFOAM/ettner-1.7.1/src/thermophysicalModels/basic/lnInclude     -I/nfs/home/ettner/OpenFOAM/ettner-1.7.1/src/thermophysicalModels/specie/lnInclude     -I/nfs/home/ettner/OpenFOAM/ettner-1.7.1/src/thermophysicalModels/chemistryModel/lnInclude     -I/nfs/opt/OpenFOAM/OpenFOAM-1.7.1/src/engine/lnInclude     -I/nfs/opt/OpenFOAM/OpenFOAM-1.7.1/src/ODE/lnInclude     -I/nfs/home/ettner/OpenFOAM/ettner-1.7.1/applications/solvers/flameTracing     -I/nfs/home/ettner/OpenFOAM/ettner-1.7.1/src/interpolationLookUpTable -IlnInclude -I. -I/nfs/opt/OpenFOAM/OpenFOAM-1.7.1/src/OpenFOAM/lnInclude -I/nfs/opt/OpenFOAM/OpenFOAM-1.7.1/src/OSspecific/POSIX/lnInclude   -fPIC Make/linux64Gcc43DPOpt/ddtLookup.o -L/nfs/opt/OpenFOAM/OpenFOAM-1.7.1/lib/linux64Gcc43DPOpt \
             -L/nfs/home/ettner/OpenFOAM/ettner-1.7.1/lib/linux64Gcc43DPOpt     -lmyreactionThermophysicalModels     -lmybasicThermophysicalModels     -lmychemistryModel     -lmyspecie     -lfiniteVolume     -lcompressibleRASModels     -lcompressibleLESModels     -lengine     -lODE -lOpenFOAM -liberty -ldl   -lm -o /nfs/home/ettner/OpenFOAM/ettner-1.7.1/applications/bin/linux64Gcc43DPOpt/ddtLookup
Make/linux64Gcc43DPOpt/ddtLookup.o: In function `main':
ddtLookup.C:(.text+0x1bbd): undefined reference to `Foam::hCombustionThermo::hello()'
collect2: ld returned 1 exit status
make: *** [/nfs/home/ettner/OpenFOAM/ettner-1.7.1/applications/bin/linux64Gcc43DPOpt/ddtLookup] Error 1
Can anybody explain me what I'm doing wrong?
dohnie is offline   Reply With Quote

Old   May 17, 2011, 12:00
Default
  #2
Member
 
Robertas N.
Join Date: Mar 2009
Location: Kaunas, Lithuania
Posts: 52
Rep Power: 8
r08n is on a distinguished road
[QUOTE=dohnie;307983]
I want to add a new member function to the hCombustionThermo class. I've boiled it down to the simplest possbile problem. In hCombustionThermo.H I write:
Code:
  void hello();
You declare a function, but not define it. Try this:
Code:
void hello (){}
In general, you better not modify the existing OF classes like this.
If you need to extend some class, declare your own class inherited from the existing class, like this:
Code:
class my_hCombustionThermo : public hCombustionThermo
{
  void hello () {}
};
r08n is offline   Reply With Quote

Old   May 17, 2011, 12:06
Default
  #3
Senior Member
 
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 397
Rep Power: 12
marupio is on a distinguished road
You have a prototype for the hello() function, but no implementation of it. That is causing the problem you posted. I think you may have boiled it down too far?
marupio is offline   Reply With Quote

Old   May 19, 2011, 04:31
Default
  #4
Member
 
Florian Ettner
Join Date: Mar 2009
Location: Munich, Germany
Posts: 40
Rep Power: 8
dohnie is on a distinguished road
Thanks to both of you, I'll give it another try!
dohnie is offline   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
OpenFOAM on MinGW crosscompiler hosted on Linux allenzhao OpenFOAM Installation 127 January 30, 2009 20:08
Could you please help me about the VTKFoam liugx212 OpenFOAM Pre-Processing 5 February 13, 2008 12:31
Parallel processing problem with mpich nzy102 OpenFOAM Running, Solving & CFD 14 October 18, 2007 00:05
Droplet Evaporation Christian Main CFD Forum 2 February 27, 2007 07:27
G95 + CGNS Bruno Main CFD Forum 1 January 30, 2007 01:34


All times are GMT -4. The time now is 07:58.