[vtk-developers] Qt5 linker issues

mchinand chinander at gmail.com
Wed May 7 12:00:19 EDT 2014


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.



More information about the vtk-developers mailing list