0

当我第一次在 qt creator 中使用 vtk 时,我遇到了这个麻烦。我现在无法解决,寻求帮助。我关注了这个网站https://csuzhangxc.gitbooks.io/vtk-simple-tutorial/content/getting_started/the_first.html但我得到了这个:

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

有人知道该怎么做吗?

该项目的一些文件如下:.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

主.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();
}
4

0 回答 0