Classes and Inheritance

Hi, I have a BaseClass, defined in “BaseClass.h” and a Class inheriting from BaseClass, defined in “Class.h”. Everything is ok unless when I defined functions of BaseClass in “BaseClass.C” but decleared them in “BaseClass.h”.

the erro read as:

cling::DynamicLibraryManager::loadLibrary(): /root/CombinedFit/models/Class_C.so: undefined symbol: _ZN9BaseClassC2Ev
IncrementalExecutor::executeFunction: symbol '_ZN5ClassD1Ev' unresolved while linking [cling interface function]!
You are probably missing the definition of Class::~Class()
Maybe you need to load the corresponding shared library?
IncrementalExecutor::executeFunction: symbol '_ZN5ClassC1Ev' unresolved while linking [cling interface function]!
You are probably missing the definition of Class::Class()
Maybe you need to load the corresponding shared library?

P.S. the version of my root is V 6.20 and my systeam is Ubuntu 20.04.4 LTS on Windows 11.

Two simple solutions.

  1. In the “Class.C”, add “#include "BaseClass.C"” then “.L Class.C++
  2. In the “Class.C”, add “#include "BaseClass.h"” then first “.L BaseClass.C++” and finally “.L Class.C++

Thank you. In fact, I have used a marco to load those classes, so I don’t think the problem is not to load “.h” or “.C” files. The reason maybe from Windows Subsystem for Linux (WSL). It seems some bugs in WSL, for example Null character string str = “”, str.empty() is not true in WSL. But I’m not sure whether from WSL.

What do you get from:
std::string str = ""; std::cout << str.empty() << "\n";

BTW. Try to switch to the latest ROOT 6.26/04.

When I read blank line in file by function “getline”, I will get a non-empty string, whose length is 1.

Maybe c++ - Getline keeps on getting newline character. How can I avoid this? - Stack Overflow ? Not much ROOT in that :slight_smile:

man getline

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