有些包括工作正常,有些则没有。
我在我的cpp中使用这些:
#include <vtkGenericOpenGLRenderWindow.h>
#include <vtkNew.h>
#include <vtkPolyDataMapper.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkSphereSource.h>
#include <vtkCylinderSource.h>
#include <QVTKOpenGLWidget.h>
#include <QVTKWidget.h>
#include <vtkSmartPointer.h>
#include <vtkVersion.h>
#include <vtkParametricFunctionSource.h>
#include <vtkTubeFilter.h>
#include <vtkParametricSpline.h>
#include <vtkDoubleArray.h>
#include <vtkPoints.h>
#include <vtkPolyData.h>
#include <vtkPointData.h>
#include <vtkActor.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkCylinderSource.h>
#include <vtkProperty.h>
错误#1:
undefined reference to `vtkDebugLeaksManager::~vtkDebugLeaksManager()'
undefined reference to `vtkObjectFactoryRegistryCleanup::vtkObjectFactoryRegistryCleanup()'
以下是导致此错误的例子:
#include <vtkSphereSource.h>
#include <vtkCylinderSource.h>
#include <vtkParametricFunctionSource.h>
代码使用了很多makefile,所以我无法与你分享一切,但我想以下部分可能会有所帮助:
LIBS= -lQt5Widgets -lQt5Gui -lQt5Core -lvtkViewsQt-8.0 -lvtkViewsCore-8.0
错误#2
/usr/bin/ld: warning: libvtksys-8.0.so.1, needed by /.../libvtkCommonCore-8.0.so, not found (try using -rpath or -rpath-link)
我想这是导致以下额外错误的主要问题
.../libvtkCommonCore-8.0.so: undefined reference to `vtksys::Directory::Directory()'
.../libvtkCommonCore-8.0.so: undefined reference to `vtksys::SystemToolsManager::~SystemToolsManager()'
.../libvtkCommonCore-8.0.so: undefined reference to `vtksys::DynamicLoader::LastError()'
.../libvtkCommonCore-8.0.so: undefined reference to `vtksys::DynamicLoader::CloseLibrary(void*)'
.../libvtkCommonCore-8.0.so: undefined reference to `vtksys::SystemTools::Strucmp(char const*, char const*)'
.../libvtkCommonCore-8.0.so: undefined reference to `vtksys::Directory::GetNumberOfFiles() const'
.../libvtkCommonCore-8.0.so: undefined reference to `vtksys::SystemToolsManager::SystemToolsManager()'
.../libvtkCommonCore-8.0.so: undefined reference to `vtksys::Directory::~Directory()'
.../libvtkCommonCore-8.0.so: undefined reference to `vtksys::Directory::GetFile(unsigned long) const'
.../libvtkCommonCore-8.0.so: undefined reference to `vtksys::DynamicLoader::GetSymbolAddress(void*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
.../libvtkCommonCore-8.0.so: undefined reference to `vtksys::DynamicLoader::OpenLibrary(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
collect2: error: ld returned 1 exit status
当我想使用以下内容时会发生这种情况:
LIBS= (as above) -lvtkCommonCore-8.0
提前致谢!
答案 0 :(得分:0)
该链接器警告信息非常清楚,它建议您链接libvtksys-8.0.so.1
。
找出该文件所在目录的完整路径,然后将以下内容添加到链接器命令行:
-L<dir> -Wl,-rpath=<dir> -lvtksys-8.0