[vtkusers] Fwd: undefined reference problem while linking

Shailender Kanwar shailender.kanwar at gmail.com
Wed Dec 10 05:51:13 EST 2008


On Wed, Dec 10, 2008 at 3:20 PM, Mathieu Malaterre <
mathieu.malaterre at gmail.com> wrote:
> 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
>


Actually I am using qmake I had looked at cmake but the makefiles generated
by cmake
seemed to be too complex so I didnt use it
Is is necessary to use cmake for working with vtk ?


>> 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


Yes you are right
here I have only added libQVTK as adding other vtk libs is only increasing
the error list, each vtk library is leading to its own list of undefined
reference errors.
I have tried adding all the vtk libs but still the problem continues.
Maybe my order of linking the libraries is wrong can you tell me in what
order the libs should be linked ?

shailender
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20081210/94d6ed18/attachment.htm>


More information about the vtkusers mailing list