[vtkusers] Link to VTK library
David Doria
daviddoria at gmail.com
Mon Mar 26 08:38:24 EDT 2012
On Mon, Mar 26, 2012 at 7:26 AM, <L.Ding at surrey.ac.uk> wrote:
> Dear VTK community
>
>
>
>
>
> I am having a problem liking the VTK library to my code.
>
>
>
> I attached my Makefile in the end. But when I type make command, I always
> got following error messages.
>
>
>
> /mnt/home/yazaydin/VTKjob/MFI-nC6/YZ/main.c:650: undefined reference to
> `vtkPolyDataAlgorithm::SetInput(vtkDataObject*)'
>
> /mnt/home/yazaydin/VTKjob/MFI-nC6/YZ/main.c:654: undefined reference to
> `vtkPolyDataMapper::SetInput(vtkPolyData*)'
>
>
>
> main.o: In function `vtkGlyph3D::SetSource(vtkPolyData*)':
>
> /mnt/home/yazaydin/VTK/include/vtk-5.8/vtkGlyph3D.h:111: undefined reference
> to `vtkGlyph3D::SetSource(int, vtkPolyData*)'
>
> /mnt/home/yazaydin/VTKjob/MFI-nC6/YZ/main.c:1421: undefined reference to
> `vtkImageAlgorithm::SetInput(vtkDataObject*)'
>
>
>
>
>
>
>
> Could you give me some guidance how to link the VTK library to the code.
>
>
>
>
>
> Best regards
>
> Lifeng
>
>
>
>
>
>
>
>
>
>
>
>
>
> My Makefile
>
> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
>
>
>
> CC = g++
>
> CLINKER = g++
>
>
>
> CFLAGS = -I/mnt/home/yazaydin/VTK/include/vtk-6.0 -Wall -O3 -g -m64
>
> LIBS = -L/mnt/home/yazaydin/VTK/lib/vtk-6.0 -lvtkCommon
> -lvtkFiltering -lvtkImaging -lvtkGraphics -lvtkGenericFiltering -lvtkIO
> -lvtkRendering -lvtkVolumeRendering -lvtkHybrid -lvtkWidgets -lvtkInfovis
> -lvtkGeovis -lvtkViews -lvtkCharts -lvtkChemistry
>
>
>
> OBJS = main.o
>
> EXECS = simulate
>
>
>
> default: simulate
>
>
>
> all: $(EXECS)
>
>
>
> simulate:$(OBJS)
>
> $(CLINKER) $(OPTFLAGS) -o simulate $(OBJS) $(LIBS)
>
>
>
> clean:
>
> /bin/rm -f *.o *~ PI* $(EXECS)
>
>
>
> .c.o:
>
> $(CC) $(CFLAGS) -c $*.c
>
> .f.o:
>
> $(F77) $(FFLAGS) -c $*.f
>
>
>
>
The suggested method is to use a CMakeLists.txt file to generate a project.
Every example has an associated CMakeLists.txt file (for example:
http://www.vtk.org/Wiki/VTK/Examples/Cxx/IO/SimplePointsReader
You just need to write
target_link_libraries(YourProgram ${VTK_LIBRARIES})
and everything is taken care of for you.
David
More information about the vtkusers
mailing list