I successfully installed ROOT with Macports via
and made sure that the variant +minuit2 is installed. Then I added the Search Paths and Linking within the XCode configuration:
Targets > Build Settings > User Header Search Paths > Debug > /opt/local/libexec/root6/include/root
Targets > Build Settings > Other Linker Flags > Debug > -L/opt/local/libexec/root6/lib/root -lCore -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -lMultiProc -lpthread -Wl,-rpath,/opt/local/libexec/root6/lib/root -stdlib=libc++ -lm -ldl
which I got from
Now I wanted to the numerical minimization example (root.cern.ch/numerical-minimization)
[code]
#include “Minuit2/Minuit2Minimizer.h”
#include “Math/Functor.h”
double RosenBrock(const double *xx )
{
const double_t x = xx[0];
const double_t y = xx[1];
const double_t tmp1 = y-x*x;
const double_t tmp2 = 1-x;
return 100*tmp1*tmp1+tmp2*tmp2;
}
int main()
{
// Choose method upon creation between:
// kMigrad, kSimplex, kCombined,
// kScan, kFumili
ROOT::Minuit2::Minuit2Minimizer min ( ROOT::Minuit2::kMigrad );
min.SetMaxFunctionCalls(1000000);
min.SetMaxIterations(100000);
min.SetTolerance(0.001);
ROOT::Math::Functor f(&RosenBrock,2);
double step[2] = {0.01,0.01};
double variable[2] = { -1.,1.2};
min.SetFunction(f);
// Set the free variables to be minimized!
min.SetVariable(0,"x",variable[0], step[0]);
min.SetVariable(1,"y",variable[1], step[1]);
min.Minimize();
const double *xs = min.X();
std::cout << "Minimum: f(" << xs[0] << "," << xs[1] << "): "
<< RosenBrock(xs) << std::endl;
return 0;
}[/code]
I tested the code as a root macro and it worked fine, but trying to compile it within XCode yields the following errors:
Undefined symbols for architecture x86_64:
defined symbols for architecture x86_64:
"ROOT::Minuit2::Minuit2Minimizer::SetFunction(ROOT::Math::IBaseFunctionMultiDim const&)", referenced from:
_main in main.o
and serveral more undefined symbols.
What am I missing?