I am trying to build an application, called niftysim, which has optional visualization component that relies on VTK dependency. niftysim builds okay but when I enable the visualization component, in CMAKE, as shown below
USE_VIZ ON
VTK_DIR /home/Olumide/Downloads/src/VTK/build
I get the following linker error:
CMakeFiles/niftysim.dir/niftysim.cpp.o: In function `tledGenericVTKMeshSource<tledSurface, vtkPolyData>::Update()':
/home/Olumide/Downloads/src/NiftySim-253/source/tledGenericVTKMeshSource.tpp:32: undefined reference to `vtkPolyData::Allocate(long long, int)'
/home/Olumide/Downloads/src/NiftySim-253/source/tledGenericVTKMeshSource.tpp:44: undefined reference to `vtkPolyData::InsertNextCell(int, int, long long*)'
CMakeFiles/niftysim.dir/niftysim.cpp.o: In function `tledGenericVTKMeshSource<tledMesh, vtkUnstructuredGrid>::_AddVTKNodeAttribute(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, float const*, int)':
/home/Olumide/Downloads/src/NiftySim-253/source/tledGenericVTKMeshSource.tpp:76: undefined reference to `vtkAOSDataArrayTemplate<float>::InsertNextTupleValue(float const*)'
/home/Olumide/Downloads/src/NiftySim-253/source/tledGenericVTKMeshSource.tpp:79: undefined reference to `vtkAOSDataArrayTemplate<float>::InsertNextTupleValue(float const*)'
CMakeFiles/niftysim.dir/niftysim.cpp.o: In function `tledGenericVTKMeshSource<tledSurface, vtkPolyData>::_AddVTKNodeAttribute(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, float const*, int)':
/home/Olumide/Downloads/src/NiftySim-253/source/tledGenericVTKMeshSource.tpp:76: undefined reference to `vtkAOSDataArrayTemplate<float>::InsertNextTupleValue(float const*)'
/home/Olumide/Downloads/src/NiftySim-253/source/tledGenericVTKMeshSource.tpp:79: undefined reference to `vtkAOSDataArrayTemplate<float>::InsertNextTupleValue(float const*)'
libviz.a(tledKeyPressInteractorStyle.cpp.o):(.data.rel.ro._ZTV27tledKeyPressInteractorStyle[_ZTV27tledKeyPressInteractorStyle]+0x178): undefined reference to `vtkInteractorObserver::PickersModified()'
I have built VTK-8.0.0 (to VTK_DIR) and have verified that the undefined references are present in libvtkCommonDataModel-8.0.a and libvtkCommonCore-8.0.a, so I am at loss as to the cause of this error.
When I run make VERBOSE=1
I get
cd /home/Olumide/Downloads/src/NiftySim-253/cpu_build/source && /opt/cmake-3.19.1-Linux-x86_64/bin/cmake -E cmake_link_script CMakeFiles/niftysim.dir/link.txt --verbose=1
/usr/bin/c++ -I/home/Olumide/Downloads/src/VTK-8.0.0/build/install/include/vtk-8.0 -D_Visualisation_ -D_USE_BOOST_ -D_CMAKE_USED -g -L/home/Olumide/Downloads/src/VTK-8.0.0/build/install/lib -lvtkCommonDataModel-8.0 -lvtkCommonCore-8.0 -rdynamic -Wl,--no-as-needed -Wl,--unresolved-symbols=ignore-in-shared-libs CMakeFiles/niftysim.dir/niftysim.cpp.o -o niftysim -Wl,-rpath,/home/Olumide/Downloads/src/VTK/build/lib: libtled.a libviz.a ../xmlParser/libxmlParser.a -lboost_system -lboost_thread -lboost_date_time -lboost_chrono -lboost_atomic ... /home/Olumide/Downloads/src/VTK/build/lib/libvtkCommonDataModel-9.0.so.9.0.0 ... /home/Olumide/Downloads/src/VTK/build/lib/libvtkCommonCore-9.0.so.9.0.0
-ldl -lpthread -lgomp -lpthread
As you can see, I have also added linker options that specify the libraries containing the missing symbols, i.e.
-L/home/Olumide/Downloads/src/VTK-8.0.0/build/install/lib -lvtkCommonDataModel-8.0 -lvtkCommonCore-8.0
Unfortunately, this doesn’t do the trick either.