ACLiC does not load shared lib?

Hello, ROOTers

I have small macro including TVector3.

#include <TROOT.h>
#include <TSystem.h>
#include <TVector.h>
#include <TVector3.h>
void test_load() {
gSystem->Load(“libPhysics”);
TVector3 *v = new TVector3();
v->SetXYZ(1., 2., 3.);
}

I would like to complie this macro by the follwing way,
root [0] .x test_load.cpp++
But, I got some error messages

Info in TUnixSystem::ACLiC: creating shared library ~/harufumi/./test_load_cpp.so
dlopen error: ~/harufumi/./test_load_cpp.so:
undefined symbol: _ZN8TVector3C1Eddd
Load Error: Failed to load Dynamic link library ~/harufuumi/./test_load_cpp.so
/usr/lib/crt1.o: In function _start': /usr/lib/crt1.o(.text+0x18): undefined reference tomain’
~/harufumi/./filegh51mN.o: In function test_load()': ~/harufumi/./filegh51mN.o(.text+0x97): undefined reference toTVector3::TVector3[in-charge](double, double, double)'
collect2: ld returned 1 exit status
*** Interpreter error recovered ***

If I load libPhysics.so before compiling, it can be compiled
by above method.
root [0] gSystem->Load(“libPhysics.so”);
root [1] .x test_load.cpp++
root [2]
(in this case, commented out gSystem->Load(“libPhysics.so”)
in the macro.

So, Is it impossible to load shared lib in ACLiC mode when
I would like to use TVector3 object ?
In such a case, I can not include
gSystem->Load(“LibPhysics”) in my macro ?
Must I always load lihPhysics.so before compiling ?

I use ROOT v 3.10.02 on linux with gcc 3.2.3 .

Hi,

For now ACLiC does not have any means of investigating the code and pre-load the needed shared library. The need to pre-load the shared library your code depend on is a requirement from the compiler/OS.

Thus you have to call gSystem->Load(“libPhysics”) before loading your library.

Cheers,
Philippe.

PS. We hope to implement a way to automatic load the needed ROOT library in the coming year.