Problem with TMinuit reference with root 4.00/2 on cygwin

I have some code that works well on cygwin root 3.10 and redhat linux 3.05 that does not work on cygwin root 4.00/2 (that I built myself). I get the following error:

root [1] gSystem->CompileMacro(“try1.cc”)
Info in TUnixSystem::ACLiC: creating shared library /mount/cplagerdoc/root/xsecComb400/try1_cc.dll
/mount/cplagerdoc/root/xsecComb400/tbec_14.o(.text+0x2cd):tbec_14.cxx: undefined reference to TMinuit::TMinuit[in-charge](int)' /mount/cplagerdoc/root/xsecComb400/tbec_14.o(.text+0x52d):tbec_14.cxx: undefined reference toTMinuit::TMinuitin-charge
/mount/cplagerdoc/root/xsecComb400/tbec_14.o(.text+0x19c8):tbec_14.cxx: undefined reference to TMinuit::TMinuit[in-charge](int)' /mount/cplagerdoc/root/xsecComb400/tbec_14.o(.text+0x1f78):tbec_14.cxx: undefined reference toTMinuit::TMinuitin-charge
collect2: ld returned 1 exit status
Error in : Compilation failed!
(int)0

// -*- C++ -*-

#include "TMinuit.h"
#include <iostream>

class silly
{      
   public:
      static void init();
   private:
      static TMinuit *m_minuitPtr;
};


void fcn (Int_t &npar, Double_t *gin, Double_t &retval, 
          Double_t *par, Int_t iflag);


using namespace std;

TMinuit *silly::m_minuitPtr;


void
silly::init()
{
   Double_t arglist[10]; 
   Int_t ierflg = 0;
   Double_t value, err;
   m_minuitPtr = new TMinuit(1);
   m_minuitPtr->SetFCN(fcn);
   arglist[0] = 1.;
   m_minuitPtr->mnexcm("SET ERR", arglist, 1, ierflg);
   m_minuitPtr->mnparm(0, "xsec", 7.5, 0.0001, 0.001, 1000., ierflg);
   m_minuitPtr->mnexcm("SET PAR", arglist, 2, ierflg);
   m_minuitPtr->mnexcm("MIG", arglist, 0, ierflg);
   m_minuitPtr->GetParameter(0, value, err);
   cout << "value " << value << " err " << err << endl;
}

void fcn (Int_t &npar, Double_t *gin, Double_t &retval, 
          Double_t *par, Int_t iflag)
{
   double value = par[0];
   retval = (value - 4) * (value - 4);
   return;
}

void try1()
{
   silly::init();
}

Charles
p.s. I get the following warnings with 4.00/2 when compiling some modules that I don’t get with 3.10 (I’m pretty sure they are not affecting anything, but I thought I’d mention it just in case)

Info: resolving _gDebug by linking to __imp__gDebug (auto-import)
Info: resolving _gROOT by linking to __imp__gROOT (auto-import)

Hi Charles,

[quote=“cplager”]root [1] gSystem->CompileMacro(“try1.cc”)
Info in TUnixSystem::ACLiC: creating shared library /mount/cplagerdoc/root/xsecComb400/try1_cc.dll
/mount/cplagerdoc/root/xsecComb400/tbec_14.o(.text+0x2cd):tbec_14.cxx: undefined reference to `TMinuit::TMinuitin-charge
[…]
collect2: ld returned 1 exit status
Error in : Compilation failed![/quote]

I cannot reproduce this with 4.01/02 - for me this just works. Try to load libMinuit first, before compiling the macro. Or update to a later version. I remember we fixed something in cygwin’s Aclic after 4.00/something.

[quote=“cplager”]p.s. I get the following warnings with 4.00/2 when compiling some modules that I don’t get with 3.10 (I’m pretty sure they are not affecting anything, but I thought I’d mention it just in case)

Info: resolving _gDebug by linking to __imp__gDebug (auto-import)
Info: resolving _gROOT by linking to __imp__gROOT (auto-import)[/quote]

That’s fine, and it’s not a warning, that’s why it says “Info:” :wink: It’s ld telling you how it magically linked the correct symbols in.

Axel.

Hi,

In ROOT 4.01/02 and above when the shared library map file are generated (aka a proper build including a ‘gmake map’ directly or indirectly), ACLiC knows to load the library you are depending on. In older version you need to explicitly load them (as explaing by Axel).

Cheers,
Philippe.