[vtkusers] VTK and Qt, static build - CORRECTION

André Prins a.h.prins at gmail.com
Wed Sep 22 05:16:57 EDT 2010


Hi Gib,

If I am not mistaken, the C++ define VTK_BUILD_SHARED_LIBS handles
this. Perhaps one of the vtk-developers familiar with MinGW can
correct me if necessary. This one should be defined in vtkConfigure.h
and used by vtkWin32Header.h to setup the dllimport/dllexport
attributes. Can you check for an #undef VTK_BUILD_SHARED_LIBS in your
vtkConfigure.h?

In order to experiment a little you could also try to explicitly
undefine VTK_BUILD_SHARED_LIBS in qmake. However, this should not be
necessary as the install step of Vtk should have prepared a correct
vtkConfigure.h which should do this for you.

Regards,
Andre



On Wed, Sep 22, 2010 at 3:35 AM, Gib  Bogle <g.bogle at auckland.ac.nz> wrote:
> Hi Andre,
>
> I'm using Qt-4.6.3, and MinGW-4.4.0, but I suspect that these differences
> are not significant.  The main thing is that I'm using QtCreator/qmake, not
> cmake.  I started using the QtCreator IDE because it is what Nokia recommend
> and it's easy to use, and I have it working well (up until now!) on Windows,
> Linux and Mac-OSX.
>
> Here are a few of the undefined references:
>
> ./release\myvtk.o:myvtk.cpp:(.text+0x1c3): undefined reference to
> `_imp___ZN11vtkRenderer11RemoveActorEP7vtkProp'
> ./release\myvtk.o:myvtk.cpp:(.text+0x238): undefined reference to
> `_imp___ZN8vtkActor3NewEv'
> ./release\myvtk.o:myvtk.cpp:(.text+0x259): undefined reference to
> `_imp___ZN8vtkActor11GetPropertyEv'
> ./release\myvtk.o:myvtk.cpp:(.text+0x292): undefined reference to
> `_imp___ZN11vtkProperty8SetColorEddd'
> ./release\myvtk.o:myvtk.cpp:(.text+0x46a): undefined reference to
> `_imp___ZN9vtkProp3D10RotateWXYZEdddd'
> ./release\myvtk.o:myvtk.cpp:(.text+0x47d): undefined reference to
> `_imp___ZN11vtkRenderer8AddActorEP7vtkProp'
> ./release\myvtk.o:myvtk.cpp:(.text+0x64c): undefined reference to
> `_imp___ZN8vtkActor3NewEv'
> ./release\myvtk.o:myvtk.cpp:(.text+0x66d): undefined reference to
> `_imp___ZN8vtkActor11GetPropertyEv'
> ./release\myvtk.o:myvtk.cpp:(.text+0x6a6): undefined reference to
> `_imp___ZN11vtkProperty8SetColorEddd'
> ./release\myvtk.o:myvtk.cpp:(.text+0x6b9): undefined reference to
> `_imp___ZN11vtkRenderer8AddActorEP7vtkProp'
> ./release\myvtk.o:myvtk.cpp:(.text+0x799): undefined reference to
> `_imp___ZN11vtkRenderer11RemoveActorEP7vtkProp'
>
> There are many more (about 75), presumably one for every call to a function
> in one of the VTK libraries I'm linking (-lvtkCommon -lvtkGraphics
> -lvtkFiltering -lvtkIO -lvtkImaging -lvtkRendering -lQVTK).  Each symbol
> that isn't found corresponds to a symbol in one of the libraries.  For
> example in libvtkrendering.a there is the symbol
> __ZN11vtkRenderer11RemoveActorEP7vtkProp.
>
> It looks as if the compiler is being somehow instructed to add the "_imp_"
> prefix to all the VTK functions referenced in myvtk.cpp, i.e. all the
> functions associated with using a QVTKWidget with interactor capabilities .
>  When I look in myvtk.o I see all those "_imp_" symbols.  Unfortunately I
> understand only enough of this stuff to be dangerous.  There must be a way
> to tell qmake not to do this, but I don't think it's within my unaided
> capabilities to find out how - at least not in a reasonable amount of time.
>
> Cheers
> Gib
>
> Quoting André Prins <a.h.prins at gmail.com>:
>
>> Hi Gib,
>>
>> At the moment I have a static Vtk (5.6.0) with a dynamic Qt
>> (4.7.0-beta2) on Windows with MinGW (GCC 4.5.0) and this works without
>> any problems. I do not specify explicitly that I use a static Vtk,
>> although this may be hidden in the UseVtk cmakefile.
>>
>> In my CMakeLists.txt, I simply do the following:
>>
>>    find_package( VTK REQUIRED HINTS $ENV{VTKDIR} )
>>    include( ${VTK_USE_FILE} )
>>    # ... and further down specifying the link-libraries
>>    target_link_libraries( MyFilters vtkImaging vtkGraphics vtkIO )
>>
>> Do you use cmake for your own project as well? Which "undefined
>> references" are missing?
>>
>> Regards,
>> Andre
>>
>> On Tue, Sep 21, 2010 at 3:07 AM, Gib Bogle <g.bogle at auckland.ac.nz> wrote:
>>>
>>> Sorry, I made a mistake.  I did 'make clean' and re-generated the make
>>> files
>>> with cmake, then did make again.  Now the VTK library files have the
>>> correct
>>> symbols (no "_imp___" prefixes).  I'm not sure what my mistake was
>>> before,
>>> probably not cleaning something.
>>>
>>> Anyway, the problem with the app linker remains, many "undefined
>>> references"
>>> to  the VTK symbols prefixed by "_imp___".  Presumably I need a way to
>>> tell
>>> the IDE (which is QtCreator) to expect static versions of the library
>>> symbols.  I'm not sure whether this is a compile or a link issue.  I
>>> realize
>>> that this is now a Qt issue.
>>>
>>> BTW this is all Windows with MinGW.
>>> _______________________________________________
>>> Powered by www.kitware.com
>>>
>>> Visit other Kitware open-source projects at
>>> http://www.kitware.com/opensource/opensource.html
>>>
>>> Please keep messages on-topic and check the VTK FAQ at:
>>> http://www.vtk.org/Wiki/VTK_FAQ
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.vtk.org/mailman/listinfo/vtkusers
>>>
>>
>
>
>
> ----------------------------------------------------------------
> This message was sent using IMP, the Internet Messaging Program.
>



More information about the vtkusers mailing list