Cannot run shared object in batch mode


ROOT Version:_ 6.30/02
Platform:Linux/Fedora 34
Compiler:gcc version 11.3.1 20220421


I have a following macro named: hello_root.C

#include <iostream>
using namespace std;

void hello_root()
{
        cout << "Hello ROOT!" << endl;
}

I am not able to execute the code using shared library in the batch mode.

For my use case, I have to generate a shared library and then run it in the batch mode
as follows:

root[0] .L hello_root.C++
Info in <TUnixSystem::ACLiC>: creating shared library ./hello_root_C.so
root[1] .q

Followed by (page 27 of this document ),

root -b -q hello_root_C.so
   ------------------------------------------------------------------
  | Welcome to ROOT 6.30/02                        https://root.cern |
  | (c) 1995-2023, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for linuxx8664gcc on Jan 03 2024, 17:30:55                 |
  | From heads/master@tags/v6-30-02                                  |
  | With c++ (GCC) 11.3.1 20220421 (Red Hat 11.3.1-2)                |
  | Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q'  |
   ------------------------------------------------------------------
Processing hello_root_C.so...

without output! Is this a bug?

Can anyone test to find out what is wrong with this type of execution?

I see the same thing (on Mac). The macro is loaded but not executed.
The following is working though:

root [0] .L hello_root_C.so
root [1] hello_root()
Hello ROOT!

The doc you a referring too is quite old. It could be this behavior has changed.

@couet
I know that it works in various different ways.
This post is resulting from my previous post, for which I am still looking for an optimal solution.

It seems to be a Cling issue. May be @vvassilev has an idea about it.

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

see also [cling] Allow running named macro from shared library by ferdymercury · Pull Request #14813 · root-project/root · GitHub .