在Visual Studio 2013中使用带有Qt5.7和ITK 4.5的VTK 7.0构建我的代码时,我收到以下错误:
错误LNK2001:未解析的外部符号" protected:virtual void __cdecl vtkVRMLSource2 :: SetNthOutput(int,class vtkDataObject *)" (?SetNthOutput @ @@ vtkVRMLSource2 @@@ MEAAXHPEAVvtkDataObject Z)
此文件对应的代码是这个(`vtkVRMLSource2.cxx``):
#include "vtkVRML.h"
#include "vtkVRMLSource2.h"
#include "vtkVRMLImporter.h"
#include "vtkObjectFactory.h"
#include "vtkPolyData.h"
#include "vtkProperty.h"
#include "vtkActorCollection.h"
#include "vtkActor.h"
#include "vtkPointData.h"
#include "vtkCellData.h"
#include "vtkPolyDataMapper.h"
#include "vtkRenderer.h"
#include "vtkTransformPolyDataFilter.h"
#include "vtkAppendPolyData.h"
#include "vtkTransform.h"
#include "vtkUnsignedCharArray.h"
#include "vtkSmartPointer.h"
#include "vtkFloatArray.h"
#include "vtkDataObject.h"
#include <stdio.h>
#include <iostream>
.....
idx = 0;
while ( (actor = actors->GetNextActor()) )
{
mapper = vtkPolyDataMapper::SafeDownCast(actor->GetMapper());
if (mapper)
{
//mapper->GetInput()->Update();
//vtkPolyData *newOutput = vtkPolyData::New();
vtkPolyData *newOutput = mapper->GetInput();
//newOutput->CopyInformation(mapper->GetInput());
this->SetNthOutput(idx, newOutput);
++idx;
newOutput->Delete();
newOutput = NULL;
}
}
vtkVRMLSource2.h
文件是:
#include "vtkAlgorithm.h"
#include "vtkDataObject.h"
class vtkVRMLSource2 : public vtkAlgorithm{
public:
int vtkTypeRevisionMacro(vtkVRMLSource2, vtkAlgorithm);
void PrintSelf(ostream& os, vtkIndent indent);
static vtkVRMLSource2 *New();
int NumberOfOutputs;
vtkSetStringMacro(FileName)
vtkGetStringMacro(FileName)
int GetNumberOfOutputs();
vtkPolyData* GetOutput(int idx);
vtkPolyData* GetOutput() { return this->GetOutput(0);}
vtkSetMacro(Color,int) // usage example: this->SetColor(1);
vtkGetMacro(Color,int)
vtkBooleanMacro(Color,int)
vtkSetMacro(Append,int) // usage example: this->SetAppend(1);
vtkGetMacro(Append,int)
vtkBooleanMacro(Append,int)
protected:
vtkVRMLSource2();
~vtkVRMLSource2();
void Execute();
void InitializeImporter();
void CopyImporterToOutputs();
char* FileName;
vtkVRMLImporter *Importer;
int Color;
int Append;
virtual void SetNthOutput(int num, vtkDataObject *output);
private:
vtkVRMLSource2(const vtkVRMLSource2&);
void operator=(const vtkVRMLSource2&);
};
我在VS中链接了所有正确的VTK,ITK和Qt库。 你能帮我吗?
答案 0 :(得分:0)
您需要提供在头文件中声明的void SetNthOutput(int num, vtkDataObject *output)
的定义。你可以把它添加到vtkVRMLSource2.cxx:
void vtkVRMLSource2::SetNthOutput(int num, vtkDataObject *output)
{
//code goes here
}