[vtkusers] VTK and Qt, static build - CORRECTION

André Prins a.h.prins at gmail.com
Thu Sep 23 03:58:25 EDT 2010


Hi Gib,

Glad to hear that there is some progress. I recall from an earlier
mail that you link with "-lvtkCommon -lvtkGraphics -lvtkFiltering
-lvtkIO -lvtkImaging -lvtkRendering -lQVTK". When linking statically,
you will also need to add their dependencies: vtksys, vtkfreetype and
all the others.

Yes, this implies that you will need to find out all the necessary
dependencies and if you are unlucky you will also need to take care
with the correct order.

Regards,
Andre

On Thu, Sep 23, 2010 at 2:11 AM, Gib  Bogle <g.bogle at auckland.ac.nz> wrote:
> Hi Andre,
>
> As you suspected, the wrong vtkConfigure.h was being used.  Correcting the
> include path certainly changed things.  I now get about 2000 link errors,
> stuff like this:
>
> c:\VTK-build-4.4.0-static\bin\libvtkCommon.a(vtkObjectFactory.cxx.obj):vtkObjectFactory.cxx:(.text+0x109c):
> undefined reference to `vtksys::Directory::Directory()'
> c:\VTK-build-4.4.0-static\bin\libvtkCommon.a(vtkObjectFactory.cxx.obj):vtkObjectFactory.cxx:(.text+0x10ae):
> undefined reference to `vtksys::Directory::Load(char const*)'
> c:\VTK-build-4.4.0-static\bin\libvtkCommon.a(vtkObjectFactory.cxx.obj):vtkObjectFactory.cxx:(.text+0x10cb):
> undefined reference to `vtksys::Directory::GetNumberOfFiles() const'
> c:\VTK-build-4.4.0-static\bin\libvtkCommon.a(vtkObjectFactory.cxx.obj):vtkObjectFactory.cxx:(.text+0x10e6):
> undefined reference to `vtksys::Directory::GetFile(unsigned long) const'
> c:\VTK-build-4.4.0-static\bin\libvtkCommon.a(vtkObjectFactory.cxx.obj):vtkObjectFactory.cxx:(.text+0x14fe):
> undefined reference to `vtksys::Directory::~Directory()'
> c:\VTK-build-4.4.0-static\bin\libvtkCommon.a(vtkObjectFactory.cxx.obj):vtkObjectFactory.cxx:(.text+0x1511):
> undefined reference to `vtksys::Directory::~Directory()'
> c:\VTK-build-4.4.0-static\bin\libvtkCommon.a(vtkObjectFactory.cxx.obj):vtkObjectFactory.cxx:(.text+0x1520):
> undefined reference to `vtksys::Directory::~Directory()'
> c:\VTK-build-4.4.0-static\bin\libvtkCommon.a(vtkWin32OutputWindow.cxx.obj):vtkWin32OutputWindow.cxx:(.text+0x2dd):
> undefined reference to `GetStockObject at 4'
> c:\VTK-build-4.4.0-static\bin\libvtkCommon.a(vtkVariant.cxx.obj):vtkVariant.cxx:(.text+0x52e):
> undefined reference to `vtksys::SystemToolsManager::SystemToolsManager()'
> c:\VTK-build-4.4.0-static\bin\libvtkCommon.a(vtkVariant.cxx.obj):vtkVariant.cxx:(.text+0x54e):
> undefined reference to `vtksys::SystemToolsManager::~SystemToolsManager()'
> c:\VTK-build-4.4.0-static\bin\libvtkCommon.a(vtkVariant.cxx.obj):vtkVariant.cxx:(.text+0x704):
> undefined reference to `vtksys::SystemTools::Strucmp(char const*, char
> const*)'
> c:\VTK-build-4.4.0-static\bin\libvtkCommon.a(vtkVariant.cxx.obj):vtkVariant.cxx:(.text+0x72e):
> undefined reference to `vtksys::SystemTools::Strucmp(char const*, char
> const*)'
> c:\VTK-build-4.4.0-static\bin\libvtkCommon.a(vtkVariant.cxx.obj):vtkVariant.cxx:(.text+0x756):
> undefined reference to `vtksys::SystemTools::Strucmp(char const*, char
> const*)'
> c:\VTK-build-4.4.0-static\bin\libvtkCommon.a(vtkVariant.cxx.obj):vtkVariant.cxx:(.text+0x76c):
> undefined reference to `vtksys::SystemTools::Strucmp(char const*, char
> const*)'
> c:\VTK-build-4.4.0-static\bin\libvtkCommon.a(vtkVariant.cxx.obj):vtkVariant.cxx:(.text+0x796):
> undefined reference to `vtksys::SystemTools::Strucmp(char const*, char
> const*)'
> c:\VTK-build-4.4.0-static\bin\libvtkCommon.a(vtkDynamicLoader.cxx.obj):vtkDynamicLoader.cxx:(.text+0x68):
> undefined reference to `vtksys::DynamicLoader::LastError()'
> c:\VTK-build-4.4.0-static\bin\libvtkCommon.a(vtkDynamicLoader.cxx.obj):vtkDynamicLoader.cxx:(.text+0x74):
> undefined reference to `vtksys::DynamicLoader::LibExtension()'
> c:\VTK-build-4.4.0-static\bin\libvtkCommon.a(vtkDynamicLoader.cxx.obj):vtkDynamicLoader.cxx:(.text+0x80):
> undefined reference to `vtksys::DynamicLoader::LibPrefix()'
> c:\VTK-build-4.4.0-static\bin\libvtkCommon.a(vtkDynamicLoader.cxx.obj):vtkDynamicLoader.cxx:(.text+0x8c):
> undefined reference to
> `vtksys::DynamicLoader::GetSymbolAddress(HINSTANCE__*, char const*)'
> c:\VTK-build-4.4.0-static\bin\libvtkCommon.a(vtkDynamicLoader.cxx.obj):vtkDynamicLoader.cxx:(.text+0x98):
> undefined reference to `vtksys::DynamicLoader::CloseLibrary(HINSTANCE__*)'
> c:\VTK-build-4.4.0-static\bin\libvtkCommon.a(vtkDynamicLoader.cxx.obj):vtkDynamicLoader.cxx:(.text+0xa4):
> undefined reference to `vtksys::DynamicLoader::OpenLibrary(char const*)'
> c:\VTK-build-4.4.0-static\bin\libvtkGraphics.a(vtkSphereSource.cxx.obj):vtkSphereSource.cxx:(.text+0x46c):
> undefined reference to `vtkPoints::New()'
> c:\VTK-build-4.4.0-static\bin\libvtkGraphics.a(vtkCylinderSource.cxx.obj):vtkCylinderSource.cxx:(.text+0x2b2):
> undefined reference to `vtkPoints::New()'
>
> At least those funny symbol names are now being interpreted.  If I look in
> myvtk.o I see that it now has the same symbols (without "_imp_") that occur
> in the static VTK libraries.  What's interesting is that every "undefined
> reference" from before, i.e. all the functions called directly from
> myvtk.cpp, are not in the new error list. It looks as if these are all being
> located in the libraries (consistent with the symbol name agreement), but
> none of the library functions that they use are being located. Does this
> suggest a problem with how the libraries were created? I'm stumped now.
>  Sorry to be so obtuse - I'm sure there is a simple answer that I'm missing.
>
> Regards
> Gib
>
>
> Quoting André Prins <a.h.prins at gmail.com>:
>
>> Hi Gib,
>>
>> My apologies if it was a bit unclear. I did indeed understand that you
>> had a static Vtk, built with cmake.
>>
>> What I was trying to say: The fact that it is a static build is
>> "stored" in vtkConfigure.h: it should have #undef
>> VTK_BUILD_SHARED_LIBS. My guess was that vtkConfigure.h is incorrectly
>> installed, or that you somehow #define VTK_BUILD_SHARED_LIBS again
>> (somewhere in your own app). Have you checked this?
>>
>> Regards,
>> Andre
>>
>>
>> On Wed, Sep 22, 2010 at 11:40 AM, Gib  Bogle <g.bogle at auckland.ac.nz>
>> wrote:
>>>
>>> Hi Andre,
>>>
>>> Maybe I'm misunderstanding you, because I don't see the point of what
>>> you've
>>> just written.  Just to be sure that you are not misunderstanding me: I
>>> built
>>> static VTK libraries, using cmake.  This was successful, and the VTK
>>> examples work.  Therefore I don't think anything is wrong on the VTK
>>> side.
>>>  The problem is that the relevant file in my Qt application (myvtk.cpp,
>>> which uses the QVTKWidget) gets compiled by QtCreator to give an object
>>> file
>>> in which all the VTK function references - calls to VTK functions - are
>>> prefixed by "_imp_".  In other words QtCreator thinks it needs to compile
>>> for linking to shared VTK libraries, instead of for static libraries.
>>>
>>> Is that what you understood from what I posted before?
>>>
>>> Cheers
>>> Gib
>>>
>>>
>>> Quoting André Prins <a.h.prins at gmail.com>:
>>>
>>>> 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.
>>>>>
>>>>
>>>
>>>
>>>
>>> ----------------------------------------------------------------
>>> This message was sent using IMP, the Internet Messaging Program.
>>>
>>
>
>
>
> ----------------------------------------------------------------
> This message was sent using IMP, the Internet Messaging Program.
>



More information about the vtkusers mailing list