/usr/bin/ld: /tmp/ccnbq1jH.o: in function `__static_initialization_and_destruction_0(int, int)':
a.cpp:(.text+0x61): undefined reference to `vtksys::SystemToolsManager::SystemToolsManager()'
/usr/bin/ld: a.cpp:(.text+0x76): undefined reference to `vtksys::SystemToolsManager::~SystemToolsManager()'
collect2: error: ld returned 1 exit status
0000000000054746 T vtksys::SystemToolsManager::SystemToolsManager()
0000000000054746 T vtksys::SystemToolsManager::SystemToolsManager()
000000000005477e T vtksys::SystemToolsManager::~SystemToolsManager()
000000000005477e T vtksys::SystemToolsManager::~SystemToolsManager()
That means the symbol is there. What is the problem? However, when I build my code using vtk-6.3, there is no problem.
The reason that merely including SystemTools.hxx causes a link dependency is the following line in this header:
// This instance will show up in any translation unit that uses
// SystemTools. It will make sure SystemTools is initialized
// before it is used and is the last static object destroyed.
static SystemToolsManager SystemToolsManagerInstance;
From the gcc man page:
-l library
It makes a difference where in the command you write this option; the
linker searches and processes libraries and object files in the order
they are specified. Thus, foo.o -lz bar.o searches library z after
file foo.o but before bar.o. If bar.o refers to functions in z, those
functions may not be loaded.
And, in general, the only supported way to build against VTK is to use CMake and the targets that VTK exports (in addition to any vtk_module_autoinit() calls that may be needed to use vtkObjectFactory-using classes).