# gSystem-\>Load() undefined symbol error

**URL:** <https://root-forum.cern.ch/t/gsystem-load-undefined-symbol-error/36415>\
**Category:** ROOT\
**Created:** [October 18, 2019, 8:58pm UTC](https://root-forum.cern.ch/t/gsystem-load-undefined-symbol-error/36415 "2019-10-18T20:58:54Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![melko](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/e56c9b/32.png) [@melko](https://root-forum.cern.ch/u/melko)\
**Post date:** [October 18, 2019, 8:58pm UTC](https://root-forum.cern.ch/t/gsystem-load-undefined-symbol-error/36415/1 "2019-10-18T20:58:54Z")

</div>

I am trying to use classes generated by TFile::MakeProject in my macro. When I try to use ClassA in my macro (classA is defined in the generated library), I get undefined symbol error:

```auto
[lzer@68snzq1-wired ClassA_dbg]$ root -l libtest.C++
root [0] 
Processing libtest.C++...
Info in <TUnixSystem::ACLiC>: creating shared library /home/bloo/ClassA_dbg/./libtest_C.so
cling::DynamicLibraryManager::loadLibrary(): /home/bloo/ClassA_dbg/libtest_C.so: undefined symbol: _ZTI20ClassA
/lib/../lib64/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
/home/bloo/ClassA_dbg/libtest_C_ACLiC_dict.o: In function `int TTree::SetBranchAddress<ClassA>(char const*, ClassA*, TBranch**)':
libtest_C_ACLiC_dict.cxx:(.text._ZN5TTree16SetBranchAddressI20ClassAEEiPKcPT_PP7TBranch[_ZN5TTree16SetBranchAddressI20ClassAEEiPKcPT_PP7TBranch]+0x23): undefined reference to `typeinfo for ClassA'
libtest_C_ACLiC_dict.cxx:(.text._ZN5TTree16SetBranchAddressI20ClassAEEiPKcPT_PP7TBranch[_ZN5TTree16SetBranchAddressI20ClassAEEiPKcPT_PP7TBranch]+0x3f): undefined reference to `typeinfo for ClassA'
collect2: error: ld returned 1 exit status

```

this is a stripped down test macro which gives the above error:

```auto
#include "myLib/myLibProjectHeaders.h"
#include <TSystem.h>
#include <TChain.h>
#include <iostream>

void libtest()
{
gSystem->Load("myLib/myLib.so");
ClassA* Evt = nullptr;
TChain* mChain = new TChain("Tree1");
mChain->Add("testfile.root");
mChain->SetBranchAddress("BranchA",Evt);
std::cout<<"loaded"<<std::endl;
for(ULong64_t iev=0;iev<mChain->GetEntries();iev++)
{
	mChain->GetEntry(iev);
	if(iev%20==0)	std::cout<<iev<<std::endl;
}
std::cout<<"finni"<<std::endl;
}

```

Any ideas what i’m doing wrong here?  
Thanks in advance.

_ROOT Version:_ 6.16/00  
_Platform:_ CentOS 7  
_Compiler:_ gcc 7.3.0

* * *

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [October 19, 2019, 4:24am UTC](https://root-forum.cern.ch/t/gsystem-load-undefined-symbol-error/36415/2 "2019-10-19T04:24:10Z")

</div>

With ROOT 6 this can be a bit tricky.  
I guess the best idea (which should work with ROOT 5 and 6) is to create a simple local “rootlogon.C” file in your “[current working directory](https://en.wikipedia.org/wiki/Working_directory)”:

```auto
void rootlogon(void) { // rootlogon.C ...
  // std::cout << "... rootlogon.C ..." << std::endl;
  gSystem->Load("myLib/myLib.so");
} // ... rootlogon.C

```

and remove the “gSystem-\>Load(...);” statement from the “libtest.C”.

---

<div class="post-metadata">

**Author:** ![OSchaile](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/o/e495f1/32.png) [@OSchaile](https://root-forum.cern.ch/u/OSchaile)\
**Post date:** [October 21, 2019, 8:02am UTC](https://root-forum.cern.ch/t/gsystem-load-undefined-symbol-error/36415/3 "2019-10-21T08:02:13Z")

</div>

May be this helps:

> [@rootlogon.C 6.10.06](https://root-forum.cern.ch/t/rootlogon-c-6-10-06/26557):
>
> Dear Rooters, the following rootlogon.C worked with root 5 (CINT): { // #include "mca8000.h" //{ gROOT-\>ProcessLine(".L mca8000.cxx+"); //} //{ // gSystem-\>Load("mca8000\_cxx.so"); //} MCA8000 \*mca = new MCA8000(); } It works line by line at the root prompt. I tried different things (see commented lines), no success Thanks for help Otto

Otto

---

<div class="post-metadata">

**Author:** ![melko](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/e56c9b/32.png) [@melko](https://root-forum.cern.ch/u/melko)\
**Post date:** [October 21, 2019, 10:43pm UTC](https://root-forum.cern.ch/t/gsystem-load-undefined-symbol-error/36415/4 "2019-10-21T22:43:03Z")

</div>

Hey, so I tried this rootlogon in my wd and am still getting the undefined symbol error.

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [October 22, 2019, 6:30am UTC](https://root-forum.cern.ch/t/gsystem-load-undefined-symbol-error/36415/5 "2019-10-22T06:30:39Z")

</div>

Try (see [TSystem::Load](https://root.cern.ch/doc/master/classTSystem.html#a6ff4c4c6cd8a75a199a30dd94359f205) for error codes):

```auto
void rootlogon(void) { // rootlogon.C ...
  // std::cout << "... rootlogon.C ..." << std::endl;
  int v = gSystem->Load("myLib/myLib.so");
  if (v != 0) std::cout << "Error loading myLib: " << v << std::endl;
} // ... rootlogon.C

```

---

<div class="post-metadata">

**Author:** ![ahesam](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ahesam/32/19455_2.png) [@ahesam](https://root-forum.cern.ch/u/ahesam)\
**Post date:** [October 22, 2019, 3:50pm UTC](https://root-forum.cern.ch/t/gsystem-load-undefined-symbol-error/36415/6 "2019-10-22T15:50:08Z")

</div>

Maybe relevant here: [Rootcling ignores loading of library within macro](https://root-forum.cern.ch/t/rootcling-ignores-loading-of-library-within-macro/35094/4)

---

<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:** [November 5, 2019, 3:50pm UTC](https://root-forum.cern.ch/t/gsystem-load-undefined-symbol-error/36415/7 "2019-11-05T15:50:12Z")

</div>

Closed on November 5, 2019, 3:50pm UTC

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