Problem using a class loaded dynamically

I have several utility classes that I used from my other macros. I used to load this macros in CINT using TROOT::LoadMacro() and I could use them immediately. It seems not to be the case in ROOT 6.05.02 since when I try to do that I get errors like the one below:

IncrementalExecutor::executeFunction: symbol '_ZN9TestClass3fooEv' unresolved while linking [cling interface function]!
You are probably missing the definition of TestClass::foo()
Maybe you need to load the corresponding shared library?

It can be reproduced with the code in the following three files:
TestClass.h

#pragma once

class TestClass {
 public:
  TestClass();
  ~TestClass();
  
  void foo();
};

TestClass.C

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

TestClass::TestClass() {std::cout<< "TestClass cnstr" << std::endl;}
TestClass::~TestClass() {std::cout<< "TestClass dstrc" << std::endl;}
void TestClass::foo() {std::cout<< "TestClass foo" << std::endl;}}

TestClass.C

#include "TestClass.h"
#include "TROOT.h"

void Test() {
  gROOT->LoadMacro("TestClass.C+");
  TestClass* tc = new TestClass();
  tc->foo();
}

Any hint on how to deal with this situation will be very much welcome.

Hi,

The replacement needed, as the CINT interpretation as been replaced by an incremental compilation, is to use R__LOAD_LIBRARY:

[code]R__LOAD_LIBRARY(TestClass.C+)

#include “TestClass.h”
#include “TROOT.h”

void Test() {
TestClass* tc = new TestClass();
tc->foo();
}[/code]

Cheers,
Philippe.

That was a really quick answer. Thanks a lot Philippe!