When I used vtk in qt creator firstly, I came into this trouble. And I cannot solve it now, asking for some help. I followed this website https://csuzhangxc.gitbooks.io/vtk-simple-tutorial/content/getting_started/the_first.html but I got this:
error: /usr/local/lib//libvtkRenderingOpenGL2-8.2.a(vtkXRenderWindowInteractor.cxx.o): undefined reference to symbol 'XGetWindowAttributes'
/usr/lib/x86_64-linux-gnu/libX11.so.6:-1: error: error adding symbols: DSO missing from command line
Somebody know what to do?
Some file of the project are following: .pro:
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11
DEFINES += QT_DEPRECATED_WARNINGS
INCLUDEPATH += /usr/local/include/vtk-8.2/
LIBS += -L/usr/local/lib/ \
-lvtkGUISupportQt-8.2 \
-lvtkIOImage-8.2 \
-lvtkInteractionImage-8.2 \
-lvtkRenderingCore-8.2 \
-lvtkCommonExecutionModel-8.2 \
-lvtkCommonCore-8.2 \
-lvtkRenderingOpenGL2-8.2 \
-lvtkInteractionStyle-8.2 \
SOURCES += \
main.cpp \
mainwindow.cpp
HEADERS += \
mainwindow.h
FORMS += \
mainwindow.ui
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
main.cpp:
#include "mainwindow.h"
#include <QApplication>
#include<vtkAutoInit.h>
VTK_MODULE_INIT(vtkRenderingOpenGL2)
VTK_MODULE_INIT(vtkInteractionStyle)
#include "vtkImageViewer.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkRenderer.h"
#include "vtkPNGReader.h"
#include "QVTKWidget.h"
#include "vtkImageData.h"
#include "vtkActor.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QVTKWidget widget;
char filename[] = "/home/bichongke/Downloads/dinosaur.png";
vtkPNGReader* reader =vtkPNGReader::New();
reader->SetFileName(filename);
reader->Update();
vtkImageViewer* imageView = vtkImageViewer::New();
imageView->SetInputConnection(reader->GetOutputPort());
widget.SetRenderWindow(imageView->GetRenderWindow());
imageView->SetupInteractor(widget.GetRenderWindow()->GetInteractor());
imageView->SetColorLevel(138.5);
imageView->SetColorWindow(233);
int* dims = reader->GetOutput()->GetDimensions();
widget.resize(dims[0],dims[1]);
widget.show();
a.exec();
imageView->Delete();
reader->Delete();
return 0;
//MainWindow w;
//w.show();
//return a.exec();
}