As I am trying to learn C++ using the codes in this website, I encountered the following function evaluation code:
[code]#include “Math/IFunction.h”
class MyFunction: public ROOT::Math::IBaseFunctionOneDim
{
double DoEval(double x) const
{
return x*x;
}
ROOT::Math::IBaseFunctionOneDim* Clone() const
{
return new MyFunction();
}
};[/code]
I am compiling it using this command:
And I am receiving the following error:
/usr/lib/gcc/i686-redhat-linux/4.9.2/../../../crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
collect2: error: ld returned 1 exit status
I even tried to add main() function to the code. However, it still doesn’t work. I am writing my codes in my Fedora21 Linux and I think I have installed all the required root softwares on my machine. Do you know if I am doing something incorrectly? Your help is greatly appreciated.
When you added the main function the error should have greatly changed. What are you trying to accomplish? The code snippet you gave provide the declaration of a class but does not do any action in particular. What tutorials or documentation are following?
This is typically exercise to check how “Plotting Measurement” works. But I get something like this:
root [3] TGraphErrors *gr=new TGraphErrors(“ExampleData.txt”)
Error in TGraphErrors::TGraphErrors: Cannot open file: ExampleData.txt, TGraphErrors is Zombie
I’m not sure that understand what does mean “existing in current directory”. Because I’ve just opened this file. And I know path to this file. Maybe I should cut+paste it to another place?
“In the current subdirectory” means that his file must be present in the subdirectory in which you start “root”.
You can also explicitly give the full path to this file when creating TGraphErrors (then this file can be anywhere, of course).