GSLRandomEngine undefined symbols

Hi,

I’m trying to use the GSLRandomEngine class in a compiled program.

#include <iostream>
#include <Math/GSLRndmEngines.h>

int main()
{
   ROOT::Math::GSLRandomEngine rng;
   rng.Initialize();
   std::cout << rng.Rndm() << std::endl;
   return 0;
}

This example program works fine when i load it in the root interpreter, but when I try to compile it with

g++ `root-config --cflags --glibs` -o example example.cpp

I get the following error:

Undefined symbols for architecture x86_64:
  "ROOT::Math::GSLRandomEngine::Initialize()", referenced from:
      _main in ex-8d14d6.o
  "ROOT::Math::GSLRandomEngine::GSLRandomEngine()", referenced from:
      _main in ex-8d14d6.o
  "ROOT::Math::GSLRandomEngine::~GSLRandomEngine()", referenced from:
      _main in ex-8d14d6.o
  "ROOT::Math::GSLRandomEngine::operator()() const", referenced from:
      ROOT::Math::GSLRandomEngine::Rndm() const in ex-8d14d6.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

What does this mean, and what can I do to fix it?

_ROOT Version: 6.28/00, from conda-forge
Platform: macos 10.15.7
Compiler: Apple clang version 12.0.0 (clang-1200.0.32.29)


I guess @moneta can help.

$(root-config --cxx --cflags) -O2 -Wall -Wextra -o example example.cpp $(root-config --libs) -lMathMore

1 Like