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

symbol lookup error

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 3, 2012, 07:56
Default symbol lookup error
  #1
Senior Member
 
Robert Castilla
Join Date: Apr 2009
Location: Spain
Posts: 109
Rep Power: 17
rcastilla is on a distinguished road
I have seen several threads with this same title, but I am still unable to solve my problem.

I have defined a new transport model and it compiles fine, but when I run the solver, it gives the following error:


undefined symbol: _ZN4Foam12gearDistDataINS_13wallPointDataINS_6Vect orIdEEEEEC2ERKNS_6fvMeshERNS_14GeometricFieldIS3_N S_12fvPatchFieldENS_7volMeshEEERKbRKNS_4ListINS_6w ordReEEE

(gearDistData is an small modification of wallDistData)

I think that there is some dependence with a library which has not been satisfied. How can I know what library? In the options file for the model I have put the libraries:

LIB_LIBS = \
-lOpenFOAM \
-lmeshTools \
-lincompressibleTransportModels \
-lfiniteVolume

What is missing?

Thank you

Robert
rcastilla is offline   Reply With Quote

Old   October 4, 2012, 11:28
Default
  #2
Senior Member
 
Robert Castilla
Join Date: Apr 2009
Location: Spain
Posts: 109
Rep Power: 17
rcastilla is on a distinguished road
I have some additional information.

I have modified the wallDistData in order to calculate the distance to a particular wall (given as argument). The wallDistData class uses a template type for transfer. I have conserved this (despite I will transfer only wallPointData, for the wallDistReflection function). But when I type "ld" for my library, it says:

undefined reference to `Foam::gearDistData<Foam::wallPointData<Foam::Vect or<double> > >::~gearDistData()'
undefined reference to `Foam::gearDistData<Foam::wallPointData<Foam::Vect or<double> > >::correct()'
undefined reference to `Foam::gearDistData<Foam::wallPointData<Foam::Vect or<double> > >::gearDistData(Foam::fvMesh const&, Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh>&, bool const&, Foam::List<Foam::wordRe> const&)'

These functions are correctly defined in gearDataDist. But I don't know if this is an issue with the template class. Could I perhaps modify the gearDistData to use with just wallPointData?

Any comment will be welcome

Thanks

Robert
rcastilla is offline   Reply With Quote

Old   October 4, 2012, 18:09
Default
  #3
Senior Member
 
Robert Castilla
Join Date: Apr 2009
Location: Spain
Posts: 109
Rep Power: 17
rcastilla is on a distinguished road
I think I have found a workaround.

As I have seen in some C++ forums, when a class is defined with a template, the full implementation has to be declared in the header file (the reason of that, no idea...) Probably this is the reason of this text at the end of the wallDistData.H:

#ifdef NoRepository
# include "gearDistData.C"
#endif

Initially I commented this text to avoid duplications of definitions. Now I have uncommented it, and commented the gearDistData.C in the Make/files file, and it seems to work. At least, it gives no undefined symbols...

Hope it will be useful for somebody.

Robert
rcastilla is offline   Reply With Quote

Old   October 5, 2012, 08:00
Default
  #4
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Greetings Robert,

Many thanks for sharing the steps of your endeavor!

I wrote some stuff about "NoRepository" sometime ago here: http://www.cfd-online.com/Forums/ope...epository.html

Last but not least: do not underestimate the coding reasoning behind OpenFOAM's code If it was done in this way, there should always be a meaning to it... and sometimes "performance" is very likely the reason
Which is why we sometimes get lost in the middle of its code......

Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   October 5, 2012, 08:22
Default
  #5
Senior Member
 
Robert Castilla
Join Date: Apr 2009
Location: Spain
Posts: 109
Rep Power: 17
rcastilla is on a distinguished road
Hi, Bruno,

I apologize for the misunderstanding. Never in my mind to underestimate the reasons of the OF programmers to do thinks like they do . I can understand the reason to include a NoRepository flag in order to explicitly have the coding in the header file. But I still don't understand (and I think that is it out of my scope) why a c++ template class has to be entirely defined in the header file.

Thank you for your link to the NoRepository thread . Unfortunately, I haven't seen it before. It could save me a lot of time...

Best regard

Robert
rcastilla is offline   Reply With Quote

Old   October 5, 2012, 08:29
Default
  #6
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Quote:
Originally Posted by rcastilla View Post
But I still don't understand (and I think that is it out of my scope) why a c++ template class has to be entirely defined in the header file.
The mnemonic is simple: C++ Templates are basically C Macros on steroids!
They're not object code unless they're actually used somewhere! And they can only be used if and when they're actually visible...
__________________
wyldckat is offline   Reply With Quote

Reply


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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Undeclared Identifier Errof UDF SteveGoat Fluent UDF and Scheme Programming 7 October 15, 2014 07:11
Compile problem ivanyao OpenFOAM Running, Solving & CFD 1 October 12, 2012 09:31
How to install CGNS under windows xp? lzgwhy Main CFD Forum 1 January 11, 2011 18:44
[Netgen] Installation of Netgen in SuSE Linux 92 edvardsenpriv OpenFOAM Meshing & Mesh Conversion 23 January 16, 2009 06:12
user defined function cfduser CFX 0 April 29, 2006 10:58


All times are GMT -4. The time now is 11:28.