|
[Sponsors] |
Compilation error "Foam::xyz has not been declared" |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
August 22, 2011, 13:28 |
Compilation error "Foam::xyz has not been declared"
|
#1 | ||
Senior Member
Arne Stahlmann
Join Date: Nov 2009
Location: Hanover, Germany
Posts: 209
Rep Power: 18 |
Hi all,
I guess this is a simple questions to all of you knowing c++ programming, but I don't get it right now: I have a file test.C including a function call Quote:
When compiling, I get the error message Quote:
What do I have to include at which position, so that the function call finds my function? Arne |
|||
August 23, 2011, 04:09 |
|
#2 |
Senior Member
Kathrin Kissling
Join Date: Mar 2009
Location: Besigheim, Germany
Posts: 134
Rep Power: 17 |
Hello Arne,
did you #inlcude "xyz.H" into your main file? Did you compile the xyz.C? Best Kathrin |
|
August 23, 2011, 13:48 |
|
#3 | |
Senior Member
Arne Stahlmann
Join Date: Nov 2009
Location: Hanover, Germany
Posts: 209
Rep Power: 18 |
Hi Kathrin,
thanks for the hint with compiling xyz.C. This itself originally compiled before, but due to some changes, it maybe could not be found now. Including xyz.C in my test.C now solved it. But is including a .C file via #include a good idea? Normally, I only do this with header files. Alternatively, how do I compile the single xyz.C file before? wmake xyz.C gives Quote:
|
||
August 23, 2011, 18:38 |
|
#4 | |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
Greetings to all!
@Arne: have you ever done the following exercise? http://openfoamwiki.net/index.php/Ho...ure_to_icoFoam I'll give you a hint "Make/files": Quote:
Bruno
__________________
|
||
August 24, 2011, 03:43 |
|
#5 |
Senior Member
Arne Stahlmann
Join Date: Nov 2009
Location: Hanover, Germany
Posts: 209
Rep Power: 18 |
Thanks Bruno,
I know this exercise . For me it's not straight forward due to the fact that I have two C-files test.C and xyz.C, whereas test.C holds the main() function and xyz.C only some methods which have to be called from within test.C For "compile the single xyz.C file before" I meant something like g++ xyz.C with additional arguments (as this does not know the Foam files). Nevertheless, #include xyz.C works so far. Arne |
|
August 24, 2011, 03:49 |
|
#6 |
Senior Member
Kathrin Kissling
Join Date: Mar 2009
Location: Besigheim, Germany
Posts: 134
Rep Power: 17 |
Arne,
do you have a Make folder in your directory? The just edit the "file" file and add Code:
xyz.C test.C EXE = $(FOAM_USER_APPBIN)/test //or whatever you wanna call it Run wmake. Just try! |
|
August 24, 2011, 03:52 |
|
#7 |
Senior Member
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 30 |
To build upon Bruno's answer, the usual way to write the makefile is:
Code:
xyz.C main.C EXE = $(FOAM_USER_APPBIN)/my_icoFoam |
|
August 24, 2011, 03:56 |
|
#8 |
Senior Member
Kathrin Kissling
Join Date: Mar 2009
Location: Besigheim, Germany
Posts: 134
Rep Power: 17 |
Now I got it.
Thank you Anton for making this point for me. There's no .H file. I was so much into the nomal class structure, so I totally misunderstood. I never wanted to include some .C file. Maybe it would be a good idea to program that way that it will match the normal OpenFOAM structure but its not necessary. You may find the fowmNew scripts quite helpfull. There's a link in the wiki. I just cannot remember. Best Kathrin |
|
August 24, 2011, 04:07 |
|
#9 |
Senior Member
Arne Stahlmann
Join Date: Nov 2009
Location: Hanover, Germany
Posts: 209
Rep Power: 18 |
Thanks to all, now I got it as well .
Arne |
|
August 31, 2011, 06:22 |
|
#10 |
Senior Member
Florian Krause
Join Date: Mar 2009
Location: Munich
Posts: 103
Rep Power: 17 |
Hi,
I think I have a similar problem as reported by Arne. I have solver (its structure is similar to pisoFoam) and I would like to add an overloaded function (lets call the function simple). The function looks like Code:
volScalarField simple(volScalarField& unfiltered) { return fvc::surfaceSum ( mesh().magSf()*fvc::interpolate(unfiltered) )/fvc::surfaceSum(mesh().magSf()); } What I did so far: I have a file simplefilter.C with the code above and a file simplefilter.H which contains Code:
volScalarField simple(volScalarField& unfiltered); Hope it is not confusing so far?! Now, this is already pretty messed up and running wmake gives me the expected error: volScalarField, volVectorField and volTensorField do not name a type. Well, I don't include the corresponding headers like fvCFD.H etc. in simplefilter.C which probably cause the error... My question, is there a more simple (also elegant) way to add an overloaded function as the one mentioned above to a solver? Any hints are much appreciated! Best, Florian |
|
September 1, 2011, 18:29 |
|
#11 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
Greetings Florian,
OK, when in doubt: isolate and conquer! Step one: put your new functions in the same file as the main .C file and put them before the main function, but after the includes. This way you know the definitions are available on-site. Step two: replace said functions with a single include of a header that has those functions. Seems pointless, but it's a helpful mnemonic. Step three:
The premise for this last step: fvCFD.H is included before newStuff.H, therefore the necessary definitions are ready to be used when the compiler seems the newStuff.H file. Best regards, Bruno
__________________
Last edited by wyldckat; September 1, 2011 at 18:30. Reason: typos found after posting... |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
errors during compilation and installation of OpenFOAM-1.7.x on Ubuntu 10.04 | ftec | OpenFOAM Installation | 7 | February 23, 2011 07:07 |
Compilation Order and Single Precision Issues | gocarts | OpenFOAM Bugs | 1 | October 14, 2009 18:19 |
Compilation error with uparm.f | Raghu | Siemens | 2 | May 30, 2007 03:09 |
Compilation Error.... | Arnab | Siemens | 4 | September 12, 2004 16:54 |