Error 'ROOT::Math::Util' has not been declared raised during the building of the Bayesian Analysis Toolkit

Error message:

/bin/bash ../libtool  --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H -I. -I..    -pthread -std=c++17 -m64 -Wall -fPIC -I../BAT -I.includes -I/home/shenyp09/dev/root/install/include  -O2 -Wno-unknown-pragmas  -MT BCIntegrate.lo -MD -MP -MF .deps/BCIntegrate.Tpo -c -o BCIntegrate.lo BCIntegrate.cxx
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I.. -pthread -std=c++17 -m64 -Wall -fPIC -I../BAT -I.includes -I/home/shenyp09/dev/root/install/include -O2 -Wno-unknown-pragmas -MT BCIntegrate.lo -MD -MP -MF .deps/BCIntegrate.Tpo -c BCIntegrate.cxx  -fPIC -DPIC -o .libs/BCIntegrate.o
BCIntegrate.cxx:36:19: error: 'ROOT::Math::Util' has not been declared
   36 | using ROOT::Math::Util::ToString;
      |                   ^~~~
In file included from ../BAT/BCEngineMCMC.h:28,
                 from ../BAT/BCIntegrate.h:26,
                 from BCIntegrate.cxx:12:
BCIntegrate.cxx: In member function 'void BCMinimizer::Wrapper::Init(const std::vector<double>&, int)':
BCIntegrate.cxx:114:74: error: 'ToString' was not declared in this scope; did you mean 'TString'?
  114 |                 BCLOG_ERROR(std::string("Cannot add fixed parameter ") + ToString(i) + " to minuit");
      |                                                                          ^~~~~~~~
../BAT/BCLog.h:31:50: note: in definition of macro 'BCLOG_INTERNAL_OUT'
   31 |       (std::string(__PRETTY_FUNCTION__) + ": " + s); \
      |                                                  ^
BCIntegrate.cxx:114:17: note: in expansion of macro 'BCLOG_ERROR'
  114 |                 BCLOG_ERROR(std::string("Cannot add fixed parameter ") + ToString(i) + " to minuit");
      |                 ^~~~~~~~~~~
BCIntegrate.cxx:122:68: error: 'ToString' was not declared in this scope; did you mean 'TString'?
  122 |                 BCLOG_ERROR(std::string("Cannot add parameter ") + ToString(i) + " to minuit");
      |                                                                    ^~~~~~~~
../BAT/BCLog.h:31:50: note: in definition of macro 'BCLOG_INTERNAL_OUT'
   31 |       (std::string(__PRETTY_FUNCTION__) + ": " + s); \
      |                                                  ^
BCIntegrate.cxx:122:17: note: in expansion of macro 'BCLOG_ERROR'
  122 |                 BCLOG_ERROR(std::string("Cannot add parameter ") + ToString(i) + " to minuit");
      |                 ^~~~~~~~~~~
make[3]: *** [Makefile:595: BCIntegrate.lo] Error 1

Related Code in BCIntegrate.cxx:

using ROOT::Math::Util::ToString;
...

    std::vector<double> newstart;
    if (start.empty())
        // if empty, set to center, with fixed values fixed
        newstart = adapt.m->GetParameters().GetRangeCenters();
    else
        newstart = start;

    for (unsigned i = 0; i < adapt.m->GetNParameters(); ++i) {
        const BCParameter& p = adapt.m->GetParameter(i);
        if (p.Fixed()) {
            const bool success = min.SetFixedVariable(i, p.GetName(),
                                 newstart.at(i));
            if (!success) {
                BCLOG_ERROR(std::string("Cannot add fixed parameter ") + ToString(i) + " to minuit");
            }
        } else {
            const bool success = min.SetLimitedVariable(i, p.GetName(),
                                 newstart.at(i),
                                 p.GetRangeWidth() / 100.,
                                 p.GetLowerLimit(), p.GetUpperLimit());
            if (!success) {
                BCLOG_ERROR(std::string("Cannot add parameter ") + ToString(i) + " to minuit");
            }
        }
    }
}

BCIntegrate.cxx (70.4 KB)


Please read tips for efficient and successful posting and posting code

Please fill also the fields below. Note that root -b -q will tell you this info, and starting from 6.28/06 upwards, you can call .forum bug from the ROOT prompt to pre-populate a topic.

_ROOT Version: 6.32.04
_Platform:ubuntu 24.04
_Compiler:c++ (Ubuntu 13.2.0-23ubuntu4) 13.2.0


Hi,

I am sorry to read ROOT did not work out of the box for you.

Could you please check if BAT correctly includes the necessary header file? ROOT: math/mathcore/inc/Math/Util.h Source File

Cheers,
Danilo

Thanks for your reply. I have already added options like -I/..../root/install/include in the compilation options, but I’m not sure if this means the util header file has been successfully included. I also tried adding root-config --glibs --cflags directly to the compilation options, but it didn’t solve the problem."

Solved. I add #include <Math/Util.h> in the BCIntegrate.cxx and redo the cmake and make.

1 Like

Thanks for sharing the solution with the ROOT Community!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.