The error is produced by the linker not CINT or ROOT. It is impossible to
prevent this because this is compiler/linker dependent.
The problem happens in following way.
1) You have 'extern' symbol in header file but don't have body of it in
source file. Usually this is fine.
2) makecint or rootcint parses the 'extern' declaration and generates STUB
access routine in dictionary. There the 'extern' symbol is referenced so
its' body must exist.
3) If you compile your stuff with the dictionary, missing routine is left
unresolved. But shared library can be created.
4) When you load the shared library, linker searches for the missing symbol
because it is referenced from the dictionary. But there is no body. This
causes the linker to generate an error.
There is no way preventing this automatically.
There are only 2 ways to workaround this problem.
1) Eliminate 'extern' declaration which has no body. Or enclose it by
#ifndef __MAKECINT__ as follows
#ifndef __MAKECINT__
extern void no_body_symbol();
#endif
2) If you do not like to modify header file, use '#pragma link' statement
to turn off dictionary generation.
#pragma link off function no_body_function;
#pragma link off global no_body_globalvariable;
I recommend to setup LinkDef.h file containing '#pragma link' statements
and give it at the end of header file chain.
makecint -mk Makefile -dl my.dll -H a.h b.h LinkDef.h -C++ ...
Masaharu Goto
--------------------------------
Name: Zvyagin Alexander
E-mail address: zvyagin@mx.ihep.su
Enhancement urgency: normal
ENHANCEMENT DESCRIPTION:
I have shared library with unresolved symbol.
(This symbol is described 'extern' in the C++ code.)
CINT fails to load the library with next diagnostic:
root [0] .L Mylib.so
/usr/local/root/bin/root.exe: can't resolve symbol 'symbol_name'
....
It'll be nice to produce warning, not error message(s) and
load into CINT libraries with unresolved symbol(s).
Operation System: Linux 2.0.32,
ROOT 2.00/07