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

symbol lookup error

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

Reply
 
LinkBack Thread Tools Display Modes
Old   October 3, 2012, 08:56
Default symbol lookup error
  #1
Member
 
Robert Castilla
Join Date: Apr 2009
Location: Spain
Posts: 78
Rep Power: 7
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, 12:28
Default
  #2
Member
 
Robert Castilla
Join Date: Apr 2009
Location: Spain
Posts: 78
Rep Power: 7
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, 19:09
Default
  #3
Member
 
Robert Castilla
Join Date: Apr 2009
Location: Spain
Posts: 78
Rep Power: 7
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, 09:00
Default
  #4
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 7,453
Blog Entries: 33
Rep Power: 73
wyldckat is a jewel in the roughwyldckat is a jewel in the roughwyldckat is a jewel in the roughwyldckat is a jewel in the rough
Greetings Robert,

Many thanks for sharing the steps of your endeavor!

I wrote some stuff about "NoRepository" sometime ago here: NoRepository

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, 09:22
Default
  #5
Member
 
Robert Castilla
Join Date: Apr 2009
Location: Spain
Posts: 78
Rep Power: 7
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, 09:29
Default
  #6
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 7,453
Blog Entries: 33
Rep Power: 73
wyldckat is a jewel in the roughwyldckat is a jewel in the roughwyldckat is a jewel in the roughwyldckat is a jewel in the rough
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

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
Undeclared Identifier Errof UDF SteveGoat Fluent UDF and Scheme Programming 7 October 15, 2014 08:11
Compile problem ivanyao OpenFOAM Running, Solving & CFD 1 October 12, 2012 10:31
How to install CGNS under windows xp? lzgwhy Main CFD Forum 1 January 11, 2011 19:44
Installation of Netgen in SuSE Linux 92 edvardsenpriv Open Source Meshers: Gmsh, Netgen, CGNS, ... 23 January 16, 2009 07:12
user defined function cfduser CFX 0 April 29, 2006 11:58


All times are GMT -4. The time now is 17:42.