# Cling and RDFs

**URL:** <https://root-forum.cern.ch/t/cling-and-rdfs/60400>\
**Category:** Cling\
**Tags:** rdataframe\
**Created:** [August 2, 2024, 10:52am UTC](https://root-forum.cern.ch/t/cling-and-rdfs/60400 "2024-08-02T10:52:35Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jordy\_Degens](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jordy_degens/32/35668_2.png) [@Jordy\_Degens](https://root-forum.cern.ch/u/Jordy_Degens)\
**Post date:** [August 2, 2024, 10:52am UTC](https://root-forum.cern.ch/t/cling-and-rdfs/60400/1 "2024-08-02T10:52:36Z")

</div>

I am trying to link a c++ library via cmake and use objects within RDF code. I created a “Jets” class which is basically a class with a few Rvecs as members. I get it to compile, however when I do a define call for the rdf in python like this:

```python
R.gSystem.Load("./libHHARD.so")
rd = rd.Define("jets", f"""HHARD::Jets(
            recojet_antikt4PFlow_{systematic.suffix}_pt,
            recojet_antikt4PFlow_eta, 
            recojet_antikt4PFlow_phi,
            recojet_antikt4PFlow_m,
            recojet_antikt4PFlow_ftag_quantile_DL1dv01_Continuous,
            recojet_antikt4PFlow_ftag_quantile_GN2v01_Continuous
        )"""

```

I get the following error:

```auto
IncrementalExecutor::executeFunction: symbol '_ZN5HHARD4JetsC1Ev' unresolved while linking [cling interface function]!
You are probably missing the definition of HHARD::Jets::Jets()
Maybe you need to load the corresponding shared library?
Traceback (most recent call last):
  File "/user/jdegens/analysis/dihiggs/plotting/HHARD/bin/bbttManager.py", line 43, in <module>
    analysis_manager.run_analyses_local() # runs all rdf simultaneously
  File "/user/jdegens/analysis/dihiggs/plotting/HHARD/python/utils/wrappers.py", line 12, in timeit_wrapper
    result = func(*args, **kwargs)
  File "/user/jdegens/analysis/dihiggs/plotting/HHARD/python/managers/AnalysisManager.py", line 159, in run_analyses_local
    R.RDF.RunGraphs(dfs)
cppyy.gbl.std.runtime_error: unsigned int ROOT::RDF::RunGraphs(vector<ROOT::RDF::RResultHandle>) =>
    runtime_error: 
An error occurred during just-in-time compilation in RLoopManager::Run. The lines above might indicate the cause of the crash
All RDF objects that have not run their event loop yet should be considered in an invalid state.

```

which I think is related to something going wrong with the linking of the library. The weird thing however is that within python I can do the following:

```auto
>>> import ROOT as R
>>> R.gSystem.Load("./libHHARD.so")
0
>>> rvec = R.RVec('float')((1, 2, 3))
>>> ivec = R.RVec('int')((1, 2, 3))
>>> jets = R.HHARD.Jets(rvec,rvec,rvec,rvec, ivec,ivec)
>>> jets.m_pt[0]
1.0

```

Do you have any idea what I am doing wrong? If needed I can provide the CMakeFile, the linkdef and the header file.

Thank you very much for you help

Cheers,  
Jordy

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [August 2, 2024, 10:55am UTC](https://root-forum.cern.ch/t/cling-and-rdfs/60400/2 "2024-08-02T10:55:51Z")

</div>

I guess you generated the dictionary for your class, right? Maybe @vpadulan can help

---

<div class="post-metadata">

**Author:** ![Jordy\_Degens](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jordy_degens/32/35668_2.png) [@Jordy\_Degens](https://root-forum.cern.ch/u/Jordy_Degens)\
**Post date:** [August 2, 2024, 10:57am UTC](https://root-forum.cern.ch/t/cling-and-rdfs/60400/3 "2024-08-02T10:57:12Z")

</div>

yes exactly, that all seems to work and within the simple python script I am also able to load it and create the object

---

<div class="post-metadata">

**Author:** ![Jordy\_Degens](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jordy_degens/32/35668_2.png) [@Jordy\_Degens](https://root-forum.cern.ch/u/Jordy_Degens)\
**Post date:** [August 2, 2024, 11:39am UTC](https://root-forum.cern.ch/t/cling-and-rdfs/60400/4 "2024-08-02T11:39:19Z")

</div>

I figured out that a root class needs to have a default constructer, eg. it needs to be able to be constructed without any arguments.

I had a bug in the .h file where I basically did:  
Jets();

which I changed to:  
Jets(){};

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [August 2, 2024, 11:43am UTC](https://root-forum.cern.ch/t/cling-and-rdfs/60400/5 "2024-08-02T11:43:19Z")

</div>

Oh, OK, then I suppose the issue is solved?

---

<div class="post-metadata">

**Author:** ![Jordy\_Degens](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jordy_degens/32/35668_2.png) [@Jordy\_Degens](https://root-forum.cern.ch/u/Jordy_Degens)\
**Post date:** [August 2, 2024, 2:42pm UTC](https://root-forum.cern.ch/t/cling-and-rdfs/60400/6 "2024-08-02T14:42:16Z")

</div>

It looks like it. Need to do a few more tests, but if nothing occurs then I think it is.

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [August 16, 2024, 2:42pm UTC](https://root-forum.cern.ch/t/cling-and-rdfs/60400/7 "2024-08-16T14:42:31Z")

</div>

Closed on August 16, 2024, 2:42pm UTC

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