[vtkusers] 'Undefined Reference' Error Message

Mathieu Malaterre mathieu.malaterre at kitware.com
Wed Oct 20 16:37:50 EDT 2004


Jeremy,

	What cmakelists file do you use to compile this ?
	By any chance do you have static lib of VTK somewhere in a path that 
can be found by g++ ? Compiling an example with vtk static libs 
*require* the use of cmake otherwise it's too much a trouble.

HTH
Mathieu

This one works for me:

FIND_PACKAGE(VTK)
IF (VTK_FOUND)
   INCLUDE (${VTK_USE_FILE})
ENDIF (VTK_FOUND)

ADD_EXECUTABLE(translator translator.cpp )
TARGET_LINK_LIBRARIES (translator
   vtkParallel
)

$ cat translator.cpp 

#include "vtkMPIController.h"
#include "vtkConeSource.h"

int main()
{
   vtkMPIController::New()->Delete();
   vtkConeSource::New()->Delete();
   return 0;
}


Jeremy Stout wrote:
> If I use those commands, here is what I get:
> 
> [stout at energy stout]$ cd /usr/local/lib/vtk
> [stout at energy vtk]$ nm libvtkParallel.so| c++filt| grep vtkMPIController::New
> 0016db2c W vtkMPIController::NewInstanceInternal(void) const
> 0016db50 W vtkMPIController::NewInstance(void) const
> 00107000 T vtkMPIController::New(void)
> [stout at energy vtk]$ nm libvtkGraphics.so| c++filt| grep vtkConeSource::New
> 001dcb34 W vtkConeSource::NewInstanceInternal(void) const
> 001dcb58 W vtkConeSource::NewInstance(void) const
> 000d5df0 T vtkConeSource::New(void)
> 
> It has been about a month since I compiled VTK, but I believe I
> included MPI support.
> 
> Jeremy Stout
> 
> On Wed, 20 Oct 2004 15:29:27 -0400, Mathieu Malaterre
> <mathieu.malaterre at kitware.com> wrote:
> 
>>Jeremy,
>>
>>       What is the output of:
>>
>>nm libvtkParallel.so| c++filt| grep vtkMPIController::New
>>and
>>nm libvtkGraphics.so| c++filt| grep vtkConeSource::New
>>
>>I get:
>>
>>0016d0b6 T vtkMPIController::New()
>>0016ea3c W vtkMPIController::NewInstanceInternal() const
>>
>>and
>>
>>000c821e T vtkConeSource::New()
>>000c9604 W vtkConeSource::NewInstanceInternal() const
>>
>>If you don't get anything, that mean you didn't build VTK properly, turn
>>MPI on for example
>>
>>HTH
>>Mathieu
>>
>>
>>
>>
>>Jeremy Stout wrote:
>>
>>>Even when I use this command:
>>>
>>>g++ translator.cpp -otranslator -I/usr/local/include/vtk
>>>-I/usr/local/packages/mpich/include -L/usr/local/lib/vtk/ -lvtkCommon
>>>-lvtkDICOMParser -lvtkParallel -lvtkIO -lvtkGraphics -lvtkFiltering
>>>-lvtkHybrid -lvtkImaging -lvtkRendering -lvtkexpat -lvtkfreetype
>>>-lvtkftgl -lvtkjpeg -lvtkpng -lvt
>>>ktiff -lvtkzlib -L/usr/local/packages/mpich/lib -lmpich -ldl
>>>
>>>I get:
>>>
>>>/tmp/ccPx6BGK.o(.text+0x11): In function `main':
>>>: undefined reference to `vtkMPIController::New()'
>>>/tmp/ccPx6BGK.o(.text+0x36): In function `main':
>>>: undefined reference to `vtkConeSource::New()'
>>>collect2: ld returned 1 exit status
>>>
>>>I have no idea what is causing the error and I can't continue work on
>>>my program until I fix this. Thank you for your prompt response
>>>though.
>>>
>>>Jeremy Stout
>>>
>>>On Wed, 20 Oct 2004 14:19:32 -0400, tom fogal <tfogal at apollo.sr.unh.edu> wrote:
>>>
>>>
>>>><a6bc6cc04102007277b92dab4 at mail.gmail.com>Jeremy Stout writes:
>>>>
>>>>
>>>>>Hello, I am trying to compile a VTK program with the following line:
>>>>>
>>>>>g++ translator.cpp -otranslator -I/usr/local/include/vtk
>>>>>-I/usr/local/packages/mpich/include -L /usr/local/
>>>>>lib/vtk/ -lvtkParallel  -L /usr/local/packages/mpich/lib -lmpich -ldl
>>>>
>>>>This is valid? I guess you learn something new everyday. I had always
>>>>though you could not have a space between -L and its argument, but you
>>>>seem to be using it and not getting link errors due to mpich...
>>>>
>>>>
>>>>
>>>>>Unfortunately, this results in the following error messages:
>>>>
>>>><snip>
>>>>
>>>>>/tmp/ccZVONeC.o(.text+0x11): In function `main':
>>>>>: undefined reference to `vtkMPIController::New()'
>>>>>/tmp/ccZVONeC.o(.text+0x36): In function `main':
>>>>>: undefined reference to `vtkConeSource::New()'
>>>>
>>>>You're forgetting to link in a library, my guess is vtkCommon. add in
>>>>'-lvtkCommon' to your link line and see if that fixes it. I wouldve
>>>>thought vtkMPIController would be in vtkParallel though...
>>>>
>>>>HTH,
>>>>
>>>>-tom
>>>>
>>>
>>>_______________________________________________
>>>This is the private VTK discussion list.
>>>Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
>>>Follow this link to subscribe/unsubscribe:
>>>http://www.vtk.org/mailman/listinfo/vtkusers
>>>
>>
>>
> 






More information about the vtkusers mailing list