[vtkusers] undefined reference to `vtkImageData::SetNumberOfScalarComponents(int)' ...
Абакумов Андрей
scratchboom at gmail.com
Sat Sep 4 18:27:47 EDT 2010
I try to compile a vtk example from here (
http://www.vtk.org/Wiki/VTK/Examples/Cxx/ImageData/IterateImageData)
ImageData.cpp:
*#include <vtkSmartPointer.h>*
*#include <vtkImageData.h>*
*
*
*int main(int, char *[]) {*
*
*
*
*
* **// Create an image data*
* **vtkSmartPointer <vtkImageData> imageData** **=
vtkSmartPointer<vtkImageData>::New();*
*
*
* **// Specify the size of the image data*
* **imageData->SetDimensions(2, 3, 1);*
* **imageData->SetNumberOfScalarComponents(1);*
* **imageData->SetScalarTypeToDouble();*
*
*
* **int* dims = imageData->GetDimensions();*
* **// int dims[3]; // can't do this*
*
*
* **std::cout << "Dims: " << " x: " << dims[0] << " y: " << dims[1] << " z:
"*
* **<< dims[2] << std::endl;*
*
*
* **std::cout << "Number of points: " << imageData->GetNumberOfPoints()*
* **<< std::endl;*
* **std::cout << "Number of cells: " << imageData->GetNumberOfCells()*
* **<< std::endl;*
*
*
* **//fill every entry of the image data with "2.0"*
* **for (int z = 0; z < dims[2]; z++) {*
* **for (int y = 0; y < dims[1]; y++) {*
* **for (int x = 0; x < dims[0]; x++) {*
* **double* pixel =*
* **static_cast<double*> (imageData->GetScalarPointer(x, y,*
* **z));*
* **pixel[0] = 2.0;*
* **}*
* **}*
* **}*
*
*
* **//retrieve the entries from the image data and print them to the screen*
* **for (int z = 0; z < dims[2]; z++) {*
* **for (int y = 0; y < dims[1]; y++) {*
* **for (int x = 0; x < dims[0]; x++) {*
* **double* pixel =*
* **static_cast<double*> (imageData->GetScalarPointer(x, y,*
* **z));*
* **// do something with v*
* **std::cout << pixel[0] << " ";*
* **}*
* **std::cout << std::endl;*
* **}*
* **std::cout << std::endl;*
* **}*
*
*
* **return 0;*
*}*
I compile it with command line:
*g++ -Wno-deprecated -I/home/megauser/libs/vtk-installed/include/vtk-5.6/
-L/home/megauser/libs/vtk-installed/lib/vtk-5.6/ -lvtkHybrid ImageData.cpp*
But I get this compilation errors:
*/tmp/ccVO1Ty2.o: In function `main':*
*VtkImageDataWriter.cpp:(.text+0x6b): undefined reference to
`vtkImageData::SetNumberOfScalarComponents(int)'*
*/tmp/ccVO1Ty2.o: In function `vtkImageData::SetScalarTypeToDouble()':*
*VtkImageDataWriter.cpp:(.text._ZN12vtkImageData21SetScalarTypeToDoubleEv[vtkImageData::SetScalarTypeToDouble()]+0x15):
undefined reference to `vtkImageData::SetScalarType(int)'*
*/tmp/ccVO1Ty2.o: In function
`vtkSmartPointer<vtkImageData>::~vtkSmartPointer()':*
*VtkImageDataWriter.cpp:(.text._ZN15vtkSmartPointerI12vtkImageDataED1Ev[vtkSmartPointer<vtkImageData>::~vtkSmartPointer()]+0xd):
undefined reference to `vtkSmartPointerBase::~vtkSmartPointerBase()'*
*/tmp/ccVO1Ty2.o: In function `vtkSmartPointer<vtkImageData>::New()':*
*VtkImageDataWriter.cpp:(.text._ZN15vtkSmartPointerI12vtkImageDataE3NewEv[vtkSmartPointer<vtkImageData>::New()]+0xe):
undefined reference to `vtkImageData::New()'*
*/tmp/ccVO1Ty2.o: In function
`vtkSmartPointer<vtkImageData>::vtkSmartPointer(vtkImageData*,
vtkSmartPointerBase::NoReference const&)':*
*VtkImageDataWriter.cpp:(.text._ZN15vtkSmartPointerI12vtkImageDataEC1EPS0_RKN19vtkSmartPointerBase11NoReferenceE[vtkSmartPointer<vtkImageData>::vtkSmartPointer(vtkImageData*,
vtkSmartPointerBase::NoReference const&)]+0x1b): undefined reference to
`vtkSmartPointerBase::vtkSmartPointerBase(vtkObjectBase*,
vtkSmartPointerBase::NoReference const&)'*
*collect2: ld returned 1 exit status*
*
*
How to build this example properly?
Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100905/0df9d0cc/attachment.htm>
More information about the vtkusers
mailing list