[vtkusers] Fwd: undefined reference problem while linking

Mathieu Malaterre mathieu.malaterre at gmail.com
Wed Dec 10 04:50:39 EST 2008


On Wed, Dec 10, 2008 at 7:06 AM, Shailender Kanwar
<shailender.kanwar at gmail.com> wrote:
> hi all
>
> i am a newbie to vtk. I am using vtk 5.2.
> while compiling a QT application using vtk, i keep on getting
> undefined reference error for vtk classes and methods
>
> in my program iam trying only to create a QVTKWidget object
> but i am facing a load of undefined references
>
> i have recompiled vtk many times tweaking the build settings in cmake
> but to no avail
> i even tried using vtk 5.0.4 but the same problem comes there too
> i have tried on both windows and linux but the problem doesnt go away

this is not a problem with VTK, this is a problem in your small application.

> here is a part of the error message
>
> g++ -Wl,-rpath,/usr/local/Trolltech/Qt-4.4.3/lib -o test main.o
> -L/usr/local/Trolltech/Qt-4.4.3/lib -L/usr/local/lib/vtk-5.2 -lQVTK
> -lvtkCommon -lQtGui -L/usr/local/Trolltech/Qt-4.4.3/lib
> -L/usr/X11R6/lib -pthread -lpng -lSM -lICE -pthread -pthread -lXi
> -lXrender -lXrandr -lfreetype -lfontconfig -lXext -lX11 -lQtCore -lz
> -lm -pthread -lgthread-2.0 -lglib-2.0 -lrt -ldl -lpthread

You are listing: -L/usr/local/lib/vtk-5.2
but I do not see any vtk libs afterwards. Are you using CMake ? If not
you should.

Eg.

FIND_PACKAGE(VTK REQUIRED)
INCLUDE(${VTK_USE_FILE})

ADD_EXECUTABLE(myapp main.cxx)
TARGET_LINK_LIBRARIES(myapp vtkRendering ... ) # you may need the vtkqt lib too

-- 
Mathieu



More information about the vtkusers mailing list