Assigning a class instance to a class variable compiled into different libraries

Hi,
I have a system containing a testbench module (TB) and two additional modules (M1, M2), which are controlled by the TB. TB, M1 and M2 are compiled into there own library. There is also 1 file implementing a configuration class for M1 and M2, clCFG, which is compiled into each library.
Then I want to access the clCFG instances of M1 and M2 inside TB:

TB.sv, compiled into lib TB:

clCFG = cfg_tb;
if () cfg_tb = M1.cfg;
else  cfg_tb = M2.cfg;
      .. 
do s.th. with cfg_tb
      ..

M1.sv, compiled into lib M1

  
clCFG cfg = new();

M2.sv, compiled into lib M2:

  
clCFG cfg = new();

Then I get the following error:

Error-[SV-ICA] Illegal class assignment

Expression ‘M1.cfg’ on rhs is not a class or a
compatible class and hence cannot be assigned to a class handle on lhs.
Please make sure that the lhs and rhs expressions are compatible.

Obviously, classes compiled from the same source into different libraries are incompatible. Has anyone an idea how to solve that?

Use a package. See http://go.mentor.com/package-import-versus-include

In reply to hwiese:

… of course ‘clTest’ is the class name inside the package.