[vtk-developers] Qt5 linker issues

Christopher Mullins christopher.mullins at kitware.com
Wed May 7 12:19:43 EDT 2014


Thanks Bill and mchinand!

Adding the find_package(Qt5Widgets REQUIRED) works without needing the
extra syntax inside target_link_libraries, but then of course I have to
specify

-DQt5Widgets_DIR:PATH=/home/chris/Projects/qt-5.2.1-install/5.2.1/gcc_64/lib/cmake/Qt5Widgets

which I should not have to do, because VTK already knows where that is.


On Wed, May 7, 2014 at 12:00 PM, mchinand <chinander at gmail.com> wrote:

> Christopher Mullins wrote
> > *The Problem*
> >
> > Now, I want to build a simple example.  I'll use DistanceBetweenPoints
> > [3].
> >  When I configure with VTK_DIR:PATH=/home/chris/Projects/VTK-with-qt5
> > there
> > are no errors.  When I build with make I get the following error:
> >
> > /usr/bin/ld: error: cannot find -lQt5::Widgets
> >
> > If I do the same thing, except configuring VTK with
> > BUILD_SHARED_LIBS:BOOL=OFF instead, I get this error with 3 additional
> > libraries it can't find:
> >
> > /usr/bin/ld: error: cannot find -lQt5::WebKitWidgets
> > /usr/bin/ld: error: cannot find -lQt5::OpenGL
> > /usr/bin/ld: error: cannot find -lQt5::Widgets
> > /usr/bin/ld: error: cannot find -lQt5::Sql
>
> Try adding:
>
> find_package(Qt5Widgets REQUIRED)
>
> to your CMakeLists.txt file and then change the target_link_libraries to:
>
> target_link_libraries(DistanceBetweenPoints Qt5::Widgets ${VTK_LIBRARIES})
>
> It should then compile and link. I think the syntax of Qt5::Widgets in
> target_link_libaries is only supported in CMake 2.8.11 and up. I was
> getting
> similar errors on Windows using MSVC2012. This is just a workaround though
> but I think slightly better than having to specify individually the
> necessary VTK modules. This shouldn't be required if the executable doesn't
> actually use QT, as in this example. Maybe I just have a similarly bad
> configuration as you do.
>
>
>
> --
> View this message in context:
> http://vtk.1045678.n5.nabble.com/Qt5-linker-issues-tp5726964p5727015.html
> Sent from the VTK - Dev mailing list archive at Nabble.com.
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtk-developers
>
>


-- 
Christopher Mullins
R&D Engineer
Kitware Inc.,
919.869.8871
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20140507/84a91bd3/attachment-0002.html>


More information about the vtk-developers mailing list