[vtkusers] Newbie VTK/C++ question

kitware-vtk at kulnet.kuleuven.ac.be kitware-vtk at kulnet.kuleuven.ac.be
Wed Jun 2 09:37:30 EDT 2004


---  Forwarded by news2mail for Bach <invalid at kuleuven.ac.be> ---

I'm new to VTK and rather new to C++. I want to use VTK for some 
visualisations in a CFD application. I'm using VTK 4.2

I was able to get things working using precompiled VTK binaries and 
Java, but so far all my attempts on getting it working with C++ have failed.
I tried on Windows (Visual Studio .Net) and on Debian GNU/Linux Woody 
(kernel 2.4.25 - g++ 2.95.4 20011002).



Below I'll describe what I've done (on Linux).  Please correct me in the 
likely case I did anything stupid.

1 - Compilation of VTK

I compiled VTK using CMake (as instructed in the readme: cmake -i, make 
...).
The result of this, is a set of binaries in the $VTK/bin directory.
I copied all header (.h) files and library (.a) files to respectively 
$VTK/include and $VTK/lib.
I don't know wheter this is important but in cmake I've choosen static 
linking.


2 - Compilation of application

I use one of the examples to test my VTK setup.  I compile it using
	g++ -c -I/tmp/VTK/include Cone.cxx
This completes succesfully.  However when I try to link it using
	g++ -o Cone -I/tmp/VTK/include -L/tmp/VTK/lib -lGL -lGLU -lvtkCommon 
-lvtkIO -lvtkGraphics -lvtkRendering -lvtkFiltering Cone.o
I get the following error:
	Cone.o: In function `main':
	Cone.o(.text+0x8): undefined reference to `vtkConeSource::New(void)'
	Cone.o(.text+0x70): undefined reference to `vtkPolyDataMapper::New(void)'
	Cone.o(.text+0x84): undefined reference to 
`vtkPolyDataSource::GetOutput(void)'
	Cone.o(.text+0x93): undefined reference to 
`vtkPolyDataMapper::SetInput(vtkPolyData *)'
	Cone.o(.text+0x9b): undefined reference to `vtkActor::New(void)'
	Cone.o(.text+0xc2): undefined reference to `vtkRenderer::New(void)'
	Cone.o(.text+0xd7): undefined reference to 
`vtkRenderer::AddActor(vtkProp *)'
	Cone.o(.text+0x117): undefined reference to `vtkRenderWindow::New(void)'
	Cone.o(.text+0x19b): undefined reference to 
`vtkRenderer::GetActiveCamera(void)'
	Cone.o(.text+0x1a6): undefined reference to `vtkCamera::Azimuth(double)'
	collect2: ld returned 1 exit status


Thanks in advance



More information about the vtkusers mailing list