XCode as IDE

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)

#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 );
    ROOT::Math::Functor f(&RosenBrock,2);
    double step[2] = {0.01,0.01};
    double variable[2] = { -1.,1.2};
    // Set the free variables to be minimized!
    min.SetVariable(0,"x",variable[0], step[0]);
    min.SetVariable(1,"y",variable[1], step[1]);
    const double *xs = min.X();
    std::cout << "Minimum: f(" << xs[0] << "," << xs[1] << "): "
    << RosenBrock(xs) << std::endl;
    return 0;

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?

Most probably you need to add -lMinuit2

Yes!!! Thx a lot I just added the -lMinuit2 to the other linker flags and finally it compiles.