'undefined reference' error after adding a library

I have a short script that reads a tree from a root file and generates a canvas showing a signal. The script works fine. However, I needed to add a library file called ‘libTParameters.so’ from another directory in my Makefile. After adding the file, I got an error message as follows:

/usr/bin/ld: /projects/scode/libTParameters.so: undefined reference to `TPID::Reset()’

TPID is a class and the header file where it is declared is in the /projects/scode/include directory.
My current working directory is separate from either of these. Therefore I have explicitly included the TPID.h file in my script.

What I understood so far that the library that I have added was not linked properly. Can you please help me figuring out what I am missing? I am attaching the code and the Makefile herein .

Thank you.

_ROOT Version: v6.24/06
plot.cpp (1.9 KB)
Makefile.txt (943 Bytes)

Dear @Sbecka ,

The library being added also needs to be able to reach your header file. You can for example extend the include paths seen by ROOT via gInterpreter->AddIncludePath .


I have added this in my .cpp file and received the following error,
error: expected constructor, destructor, or type conversion before ‘->’ token

Hi @Sbecka ,

It is not really clear to me what you are doing exactly. In any case, have you included the right headers? gInterpreter is defined TInterpreter.h so that should be included in your program. Also, make sure you use it inside the scope of a function and before you try to load your external library.