[vtkusers] Recursive Make, vtk project --> undefined references!

Peter Schmitt pschmitt at gmail.com
Thu Apr 27 00:09:50 EDT 2006


I get a series of "undefined reference" errors when linking a
visualization project I wrote:

visualize.o(.text+0x7): undefined reference to `vtkSphereSource::New(void)'
visualize.o(.text+0x67): undefined reference to `vtkPolyDataMapper::New(void)'
visualize.o(.text+0x7a): undefined reference to
`vtkPolyDataAlgorithm::GetOutput(void)'
visualize.o(.text+0x88): undefined reference to
`vtkPolyDataMapper::SetInput(vtkPolyData *)'
visualize.o(.text+0xa6): undefined reference to `vtkGlyph3D::New(void)'
... and so on
###############################################################################
I'm using Recursive Make like the following:
#base Makefile:
###############
viz: CC=/opt/gcc-3.3.2/bin/gcc
viz: CXX=/opt/gcc-3.3.2/bin/g++
viz: CFLAGS=-I$(PWD)/include
viz: CXXFLAGS=-I$(VTK_HOME)/include/vtk -I$(PWD)/include
viz: LDFLAGS=-L$(VTK_HOME)/lib/vtk -lvtkRendering -lvtkGraphics
-lvtkImaging -lvtkFiltering -lvtkCommon -L./vis -lvis

export CC
export CXX
export CFLAGS
export CXXFLAGS
export LDFLAGS

viz: clean libvis.a viz.o
        $(CXX) vis/libvis.a viz.o $(LDFLAGS) -o bin/viz

libvis.a:
        cd vis; make vis

#vis/Makefile:
##############
OBJS=visualize.o

.SUFFIXES: .C.a

vis: ${OBJS}
        ar rcs libvis.a ${OBJS}

clean:
        rm -f *.o *~
        rm -f libvis.a
###############################################################################
Let's look at the symbols from my object files:
$> nm libvis.a

visualize.o:
00000546 t _GLOBAL__D__Z13initializeVTKP19vtkUnstructuredGridP15vtkRenderWindowP25vtkRenderWindowInteractor
0000052a t _GLOBAL__I__Z13initializeVTKP19vtkUnstructuredGridP15vtkRenderWindowP25vtkRenderWindowInteractor
00000000 T _Z13initializeVTKP19vtkUnstructuredGridP15vtkRenderWindowP25vtkRenderWindowInteractor
000004ec t _Z41__static_initialization_and_destruction_0ii
0000022e T _Z7animatePPfS_ii
         U _ZN10vtkGlyph3D3NewEv
00000000 W _ZN10vtkGlyph3D9SetSourceEP11vtkPolyData
         U _ZN10vtkGlyph3D9SetSourceEiP11vtkPolyData
         U _ZN11vtkRenderer3NewEv
...
more "U" (undefined) symbols....  The libraries dont appear to be
linked properly.
###############################################################################


What's wrong with my syntax when linking?  This code runs fine on one
system (standard Linux Debian install) but breaks (with the "undefined
references" link errors) on another system....



More information about the vtkusers mailing list