Qt LNK2019: unresolved external symbol "__declspec(dllimport)..." VTK



  • Hello!

    I am new with Qt and VTK.
    I think I installed everything correctly (VTK in Release mode).

    I am trying to run the example in VTK/Examples/Cxx/Qt/BorderWidgetQt. I use CMake, then I open the solution in VS2010 and it builds perfectly (release mode).

    BUT, when I try to build the exact same project in Qt Creator I have this errors:

    borderwidgetqt.obj:-1: error: LNK2019: unresolved external symbol "__declspec(dllimport) public: static class vtkBorderWidget * __cdecl vtkBorderWidget::New(void)" (_imp?New@vtkBorderWidget@@SAPEAV1@XZ) referenced in function "public: static class vtkSmartPointer<class vtkBorderWidget> __cdecl vtkSmartPointer<class vtkBorderWidget>::New(void)" (?New@?$vtkSmartPointer@VvtkBorderWidget@@@@SA?AV1@XZ)

    borderwidgetqt.obj:-1: error: LNK2019: unresolved external symbol "__declspec(dllimport) public: class vtkAlgorithmOutput * __cdecl vtkAlgorithm::GetOutputPort(int)" (_imp?GetOutputPort@vtkAlgorithm@@QEAAPEAVvtkAlgorithmOutput@@H@Z) referenced in function "public: __cdecl BorderWidgetQt::BorderWidgetQt(void)" (??0BorderWidgetQt@@QEAA@XZ)

    borderwidgetqt.obj:-1: error: LNK2019: unresolved external symbol "__declspec(dllimport) public: static class vtkSphereSource * __cdecl vtkSphereSource::New(void)" (_imp?New@vtkSphereSource@@SAPEAV1@XZ) referenced in function "public: static class vtkSmartPointer<class vtkSphereSource> __cdecl vtkSmartPointer<class vtkSphereSource>::New(void)" (?New@?$vtkSmartPointer@VvtkSphereSource@@@@SA?AV1@XZ)

    It seems that Qt is having problems in finding the dll?

    My .pro file is:

    QT += core gui
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    TARGET = BorderWidgetQt
    TEMPLATE = app
    SOURCES += main.cpp
    borderwidgetqt.cpp
    HEADERS += borderwidgetqt.h
    FORMS += borderwidgetqt.ui
    INCLUDEPATH += C:\VTK-7\install\include\vtk-7.0
    LIBS += -L"C:\VTK-7\install\lib"
    -lvtkRenderingCore-7.0
    -lvtkChartsCore-7.0
    -lvtkCommonCore-7.0
    -lvtkFiltersCore-7.0
    -lvtkGUISupportQt-7.0
    -lvtkImagingCore-7.0
    -lvtkInfovisCore-7.0
    -lvtkIOCore-7.0
    -lvtkViewsCore-7.0

    How can I fix this?

    Please, I am stuck in here and I can't find any solution for that... I already tried build the project in Qt both in release and debug mode but the errors are the same...

    Thank you in advance!!


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Are you trying to build this example ?



  • Hello! Thank you!

    Yes that example! Any help?


  • Lifetime Qt Champion

    I missed something the first time I read your thread. Visual Studio 2010 ? Did you build VTK yourself with that version of VS ?


  • Qt Champions 2016

    Hi
    To add to @SGaist ,
    In Creator, you also have selected VS2010 as compiler ?



  • Hello!

    I build VTK myself with VS! I build with Release mode, should I build with Debug mode instead?

    How do I select VS as compiler in Qt?

    Thank you very much!!


  • Moderators



  • @jsulm Yes, The VS is selected as the compiler.
    Maybe the problem is the build mode?(release/debug)?

    Thank you again


  • Lifetime Qt Champion

    I might be insisting but do you have everything build with the same version of MSVC ? Same architecture ?



  • @SGaist Yes, everthing was build with MSVC same version.


  • Lifetime Qt Champion

    Wouldn't you be missing the vtkWidgets library in your .pro file ?



  • @SGaist No.
    Maybe it's because I am building my project in VS 64 bit and Qt only detects VS compiler 32 bit?
    How can I make Qt work with 64 bit?

    Thank you!!


  • Lifetime Qt Champion

    You have to install a 64bit build of Qt. You can't mix and match libraries of different architectures.

    [Edit: fixed wording... Thanks @jsulm]


  • Moderators


Log in to reply