[vtkusers] Can someone with vtk 5.2.1 please compile this code

Oleksandr Dzyubak adzyubak at gmail.com
Thu May 14 16:24:48 EDT 2009


Hi Frency,

It looks like you are not linking your code with correct libs.
Below are your code plus the CMakeLists.txt that I wrote to test your code.
Try that and tell me how it works.

************** CMakeLists.txt ********

cmake_minimum_required(VERSION 2.6)

PROJECT(simple)

# Find VTK.
FIND_PACKAGE(VTK REQUIRED)
IF(VTK_FOUND)
  INCLUDE(${VTK_USE_FILE})
ELSE(VTK_FOUND)
  MESSAGE(FATAL_ERROR
          "Cannot build without VTK.  Please set VTK_DIR.")
ENDIF(VTK_FOUND)
 
 
ADD_EXECUTABLE (
simple
simple.cxx
)

TARGET_LINK_LIBRARIES (
simple
vtkIO
)

******************* End of CMakeLists.txt *******



********* simple.cxx *********


#include "vtkShortArray.h"

int main()
{

   short arrIn[10];
   const int indmax=10;
   vtkShortArray *dataArr = vtkShortArray::New();
   dataArr->SetNumberOfValues(indmax);
   dataArr->SetValue(1, -128);

    std::cerr << "Good job! Value =  " << dataArr->GetValue(1) << std::endl;

return 0;
}

********** End of simple.cxx ********


In my case the output of your program is below.

dzyubak at debian-alex: /BUILD$ ./simple
Good job! Value =  -128
dzyubak at debian-alex: /BUILD$


Regards,

Alex


frency v wrote:
> Hello everyone,
> I wrote this simple code but it is not getting compiled.
> i am getting the following error message. pls help.
>
> Error message:- undefined reference to 
> 'vtkDataArrayTemplate<short>::Set numbervalues (long long)'
>
> Can someone compile this code  and let me know what is going wrong?
>
> Rgds
> Frency
>
> here is the code
>
> #include "vtkShortArray.h"
> int main()
> { short arrIn[10];
>     const int indmax=10;
>     vtkShortArray *dataArr = vtkShortArray::New();
>    dataArr->SetNumberOfValues(indmax);
> }
>
> Error message:- undefined reference to 
> 'vtkDataArrayTemplate<short>::Set numbervalues (long long)'
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>   




More information about the vtkusers mailing list