|
[Sponsors] |
Putting functions different files, linker error (undefined reference) |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
November 21, 2012, 09:52 |
Putting functions different files, linker error (undefined reference)
|
#1 |
New Member
Christian
Join Date: Jan 2011
Posts: 5
Rep Power: 15 |
Hey everyone,
I'm currently working on a solver and wrote some functions I would like to put in a second .C file (not the main solver code). I wrote a file helperFunctions.H Code:
#include "fvCFD.H" namespace Foam { template<class Type> void printField(OSstream& output, const GeometricField<Type, fvPatchField, volMesh>& vf); } } Code:
#include "helperFunctions.H" namespace Foam { template<class Type> void printField(OSstream& output, const GeometricField<Type, fvPatchField, volMesh>& vf) { forAll (vf.internalField(),icell) { output << vf.internalField()[icell] << " "; } } } My main solver as well as helperFunctions.C compile fine, but when it comes to linking I get the error message Code:
undefined reference to `void Foam::printField<double>(Foam::OSstream&, Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&)' Thanks, Christian |
|
November 21, 2012, 15:25 |
|
#2 |
New Member
Christian
Join Date: Jan 2011
Posts: 5
Rep Power: 15 |
Okay, after reading my Stroustrup and the C++ FAQ I got it.
It's because of how templates work... Time to refresh my C++ Skills, I guess |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Water subcooled boiling | Attesz | CFX | 7 | January 5, 2013 04:32 |
libnurbs++ | kuczmas | OpenFOAM Running, Solving & CFD | 7 | May 14, 2012 07:33 |
G95 + CGNS | Bruno | Main CFD Forum | 1 | January 30, 2007 01:34 |
Two-Phase Buoyant Flow Issue | Miguel Baritto | CFX | 4 | August 31, 2006 13:02 |
Building OpenFoAm on SGI Altix 64bits | anne | OpenFOAM Installation | 8 | June 15, 2006 10:27 |