Compiling a shared library, getting odd errors

Hello-

I’m trying to create a shared library with some code I’ve written, and I’m getting issues when I try to compile with ROOT. I’m hoping someone can tell me where I’m going wrong, as it’s linking errors and I’m unsure how to fix those.

The files can be found here: debugging_linking – Google Drive

This is what I get when I try to compile:

<tboone> root 
root [0] .L ana_cal.C+
Info in <TUnixSystem::ACLiC>: creating shared library /path/to/file/./ana_cal_C.so
cling::DynamicLibraryManager::loadLibrary(): /path/to/file/ana_cal_C.so: undefined symbol: _ZN15calAnalyzerTree10m_instanceE
/lib/../lib64/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
/path/to/file/ana_cal_C_ACLiC_dict.o: In function `calAnalyzerTree::~calAnalyzerTree()':
ana_cal_C_ACLiC_dict.cxx:(.text+0x95): undefined reference to `TTree::GetCurrentFile() const'
/path/to/file/ana_cal_C_ACLiC_dict.o: In function `ROOT::deleteArray_calAnalyzerTree(void*)':
ana_cal_C_ACLiC_dict.cxx:(.text+0x2649): undefined reference to `TTree::GetCurrentFile() const'
/path/to/file/ana_cal_C_ACLiC_dict.o: In function `calAnalyzerTree::~calAnalyzerTree()':
ana_cal_C_ACLiC_dict.cxx:(.text+0x27e5): undefined reference to `TTree::GetCurrentFile() const'
/path/to/file/ana_cal_C_ACLiC_dict.o: In function `ROOT::destruct_calAnalyzerTree(void*)':
ana_cal_C_ACLiC_dict.cxx:(.text+0x2923): undefined reference to `TTree::GetCurrentFile() const'
/path/to/file/ana_cal_C_ACLiC_dict.o: In function `ROOT::delete_calAnalyzerTree(void*)':
ana_cal_C_ACLiC_dict.cxx:(.text+0x2b09): undefined reference to `TTree::GetCurrentFile() const'
/path/to/file/ana_cal_C_ACLiC_dict.o: In function `ROOT::newArray_calAnalyzerTree(long, void*)':
ana_cal_C_ACLiC_dict.cxx:(.text+0x3bb5): undefined reference to `TTree::Class()'
ana_cal_C_ACLiC_dict.cxx:(.text+0x3cb5): undefined reference to `TTree::Class()'
/path/to/file/ana_cal_C_ACLiC_dict.o: In function `calAnalyzerTree::calAnalyzerTree(TTree*)':
ana_cal_C_ACLiC_dict.cxx:(.text+0x3dc6): undefined reference to `TTree::Class()'
/path/to/file/ana_cal_C_ACLiC_dict.o: In function `ROOT::new_calAnalyzerTree(void*)':
ana_cal_C_ACLiC_dict.cxx:(.text+0x3e4d): undefined reference to `TTree::Class()'
/path/to/file/ana_cal_C_ACLiC_dict.o: In function `ana_cal::nullify()':
ana_cal_C_ACLiC_dict.cxx:(.text+0x4b34): undefined reference to `calAnalyzerTree::m_instance'
ana_cal_C_ACLiC_dict.cxx:(.text+0x4b67): undefined reference to `TTree::GetCurrentFile() const'
ana_cal_C_ACLiC_dict.cxx:(.text+0x4b89): undefined reference to `calAnalyzerTree::m_instance'
/path/to/file/ana_cal_C_ACLiC_dict.o: In function `ana_cal::init()':
ana_cal_C_ACLiC_dict.cxx:(.text+0x4ce0): undefined reference to `calAnalyzerTree::m_instance'
ana_cal_C_ACLiC_dict.cxx:(.text+0x4d17): undefined reference to `TTree::GetCurrentFile() const'
ana_cal_C_ACLiC_dict.cxx:(.text+0x4d39): undefined reference to `calAnalyzerTree::m_instance'
ana_cal_C_ACLiC_dict.cxx:(.text+0x4e59): undefined reference to `calAnalyzerTree::m_instance'
ana_cal_C_ACLiC_dict.cxx:(.text+0x4f17): undefined reference to `calAnalyzerTree::m_instance'
ana_cal_C_ACLiC_dict.cxx:(.text+0x508f): undefined reference to `calAnalyzerTree::m_instance'
collect2: error: ld returned 1 exit status
root [1] .q

I had to slightly modify your code to be able to load it (but I’m working on Windows…). Since I cannot try it without data file, can you try with those files:
ana_cal.C (1.5 KB)
ana_cal.h (949 Bytes)
calAnalyzerTree.C (7.6 KB)
calAnalyzerTree.h (12.5 KB)

1 Like

Don’t you need to load both?

<tboone> root -l
root [0] .L calAnalyzerTree.C+
root [1] .L ana_cal.C+
1 Like

Thank you! That was indeed the problem!!!

Thanks so much! Loading it as pcanal said had it load clean and clear, I appreciate the assist!

Oh well, yes, sorry, that seemed obvious to me…

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