Hi Sina,

I just enabled MITK_BUILD_EXAMPLES in CMake, built and run MitkStep1 
successfully. To help you out here, we need more information about your setup. 
We also need to know if it works for you unmodified? By the way, you don’t need 
all that string handling stuff in your additional code, as mitk::IOUtil::Load() 
takes a std::string as its first argument – just call 
mitk::IOUtil::Load(imagePath.toStdString(), *ds).

Best,
Stefan

From: Sina Gerlach [mailto:sina.gerlac...@gmx.de]
Sent: Mittwoch, 14. Oktober 2015 10:09
To: Kislinskiy, Stefan
Cc: mitk-users@lists.sourceforge.net; rostislav.khlebni...@kcl.ac.uk
Subject: RE: [mitk-users] error LNK2019: unresolved external symbol

Hello,
so now I used the updated Tutorial with IOUtil but keep getting Linker Errors.

Main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) 
void __cdecl QmitkRegisterClasses(void)" (__imp_?QmitkRegisterClasses@@YAXXZ) 
referenced in function main

MainWindow.obj : error LNK2019: unresolved external symbol 
"__declspec(dllimport) public: __cdecl 
QmitkRenderWindow::QmitkRenderWindow(class QWidget *,class QString,class 
mitk::VtkPropRenderer *,class mitk::RenderingManager *,enum 
mitk::BaseRenderer::RenderingMode::Type)" 
(__imp_??0QmitkRenderWindow@@QEAA@PEAVQWidget@@VQString@@PEAVVtkPropRenderer@mitk@@PEAVRenderingManager@4@W4Type@RenderingMode@BaseRenderer@4@@Z)
 referenced in function "public: void __cdecl 
MainWindow::on_openButton_pressed(void)" 
(?on_openButton_pressed@MainWindow@@QEAAXXZ)

MainWindow.obj : error LNK2019: unresolved external symbol 
"__declspec(dllimport) public: virtual __cdecl 
QmitkRenderWindow::~QmitkRenderWindow(void)" 
(__imp_??1QmitkRenderWindow@@UEAA@XZ) referenced in function "public: void 
__cdecl MainWindow::on_openButton_pressed(void)" 
(?on_openButton_pressed@MainWindow@@QEAAXXZ)


What am I missing?
( I am using MITK 2015.5.2)

This is the only difference I have: (between "create data storage" and "create 
render window")
    QString imagePath = QFileDialog::getOpenFileName(this,
        "Select one or more files to open",
        "/home",
        "Images (*.DCM)");
    char* filename;
    filename = new char[imagePath.toStdString().size() + 1];
    strcpy(filename, imagePath.toStdString().c_str());
    // Create Data by reading file
    mitk::IOUtil::Load(filename, *ds);




Gesendet: Dienstag, 13. Oktober 2015 um 23:05 Uhr
Von: "Kislinskiy, Stefan" 
<s.kislins...@dkfz-heidelberg.de<mailto:s.kislins...@dkfz-heidelberg.de>>
An: "Sina Gerlach" <sina.gerlac...@gmx.de<mailto:sina.gerlac...@gmx.de>>, 
"mitk-users@lists.sourceforge.net<mailto:mitk-users@lists.sourceforge.net>" 
<mitk-users@lists.sourceforge.net<mailto:mitk-users@lists.sourceforge.net>>
Cc: "rostislav.khlebni...@kcl.ac.uk<mailto:rostislav.khlebni...@kcl.ac.uk>" 
<rostislav.khlebni...@kcl.ac.uk<mailto:rostislav.khlebni...@kcl.ac.uk>>
Betreff: AW: RE: RE: [mitk-users] error LNK2019: unresolved external symbol
Which version of MITK do you use? I guess you are reading an outdated version 
of our tutorial (which would also explain why you are using the deprecated 
DataNodeFactory instead of IOUtils). There are some major differences in the 
current version (MITK 2015.05): http://docs.mitk.org/2015.05/Step01Page.html

Do you really want to code your own application from the very beginning instead 
of just using/extending the full-featured MitkWorkbench?

Regarding MITK images in QtWidgets: I found a code snippet in my archive which 
I wrote a few years ago. I cannot guarantee that it will still work out of the 
box but you should get the idea of what is necessary to accomplish that task 
(see it as pseudo code). Maybe Rostislav has a better snippet (as far as I 
remember he displays images in his widgets, too - added him explicitly to Cc):

SNIP ====

mitk::ExtractSliceFilter::Pointer extractSliceFilter = 
mitk::ExtractSliceFilter::New();
extractSliceFilter->SetInterpolationMode(mitk::ExtractSliceFilter::RESLICE_CUBIC);
extractSliceFilter->SetResliceTransformByGeometry(image->GetGeometry());
extractSliceFilter->SetWorldGeometry(planarFigure->GetGeometry2D());
extractSliceFilter->SetVtkOutputRequest(true);
extractSliceFilter->SetInput(image);

extractSliceFilter->Update();

vtkImageData* imageData = extractSliceFilter->GetVtkOutput();

mitk::LevelWindow levelWindow;
imageDataNode->GetLevelWindow(levelWindow);

vtkSmartPointer<vtkLookupTable> lookupTable = 
vtkSmartPointer<vtkLookupTable>::New();
lookupTable->SetRange(levelWindow.GetLowerWindowBound(), 
levelWindow.GetUpperWindowBound());
lookupTable->SetSaturationRange(0.0, 0.0);
lookupTable->SetValueRange(0.0, 1.0);
lookupTable->SetHueRange(0.0, 0.0);
lookupTable->SetRampToLinear();

vtkSmartPointer<vtkMitkLevelWindowFilter> levelWindowFilter = 
vtkSmartPointer<vtkMitkLevelWindowFilter>::New();
levelWindowFilter->SetLookupTable(lookupTable);
levelWindowFilter->SetInput(imageData);
levelWindowFilter->SetMinOpacity(0.0);
levelWindowFilter->SetMaxOpacity(1.0);

int dims[3];
imageData->GetDimensions(dims);

vtkFloatingPointType clippingBounds[] = { 0.0, dims[0], 0.0, dims[1] };
levelWindowFilter->SetClippingBounds(clippingBounds);

levelWindowFilter->Update();

imageData = levelWindowFilter->GetOutput();

QImage inspectImage(
reinterpret_cast<const unsigned char*>(imageData->GetScalarPointer()),
dims[0],
dims[1],
QImage::Format_ARGB32);

inspectImage = inspectImage.rgbSwapped().mirrored(false, true); // Important, 
don't forget!!

m_Controls.inspectLabel->setPixmap(QPixmap::fromImage(inspectImage));

=== SNIP


________________________________________
Von: Sina Gerlach [sina.gerlac...@gmx.de]
Gesendet: Dienstag, 13. Oktober 2015 17:04
An: Kislinskiy, Stefan; 
mitk-users@lists.sourceforge.net<mailto:mitk-users@lists.sourceforge.net>
Betreff: Aw: RE: RE: [mitk-users] error LNK2019: unresolved external symbol

Hi Stefan,
so the first problem was solved...but then another came.

As I was saying earlier Im using the Tutorial Part1 and all I want to change is 
the way an image is used. Instead of having it in the command argument thingy I 
want to open an image using QfileDialog which works but its not displaying the 
image yet.

Heres the source code for clarification:

MainWindow.cpp
//Construktor Destruktor...

void MainWindow::on_openButton_pressed()
{
// Create a DataStorage
mitk::StandaloneDataStorage::Pointer ds = mitk::StandaloneDataStorage::New();

// Create a DataNodeFactory to read a data format supported
mitk::DataNodeFactory::Pointer reader = mitk::DataNodeFactory::New();

QString imagePath = QFileDialog::getOpenFileName(this,
"Select one or more files to open",
"/home",
"Images (*.DCM)");
char* filename;
filename = new char[imagePath.toStdString().size() + 1];
strcpy(filename, imagePath.toStdString().c_str());

try
{
reader->SetFileName(filename);
reader->Update();
// Add the node to the DataStorage
ds->Add(reader->GetOutput());
}
catch (...)
{
fprintf(stderr, "Could not open file %s \n\n", filename);
exit(2);
}

//create render window
QmitkRenderWindow *scene;

// Tell the RenderWindow which part of the datastorage to render
scene->GetRenderer()->SetDataStorage(ds);

// Initialize the RenderWindow
mitk::TimeGeometry::Pointer geo = ds->ComputeBoundingGeometry3D(ds->GetAll());
mitk::RenderingManager::GetInstance()->InitializeViews(geo);

// Select a slice
mitk::SliceNavigationController::Pointer sliceNaviController = 
scene->GetSliceNavigationController();
if (sliceNaviController)
sliceNaviController->GetSlice()->SetPos(0);

//Show image
scene->show();
scene->resize(256, 256);

ds = NULL;

The QmitkRegisterClasses() Funktion is in main.cpp, but causes the following 
error when not commented out:
error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl 
QmitkRegisterClasses(void)" (__imp_?QmitkRegisterClasses@@YAXXZ) referenced in 
function main

Also, is there a way to have the image show up in a widget of my ui-file 
(QGraphicsView)? How can they be connected?

Thank you in advance
Best regards
Sina
Gesendet: Dienstag, 13. Oktober 2015 um 14:29 Uhr
Von: "Kislinskiy, Stefan" 
<s.kislins...@dkfz-heidelberg.de<mailto:s.kislins...@dkfz-heidelberg.de>>
An: "Sina Gerlach" <sina.gerlac...@gmx.de<mailto:sina.gerlac...@gmx.de>>
Cc: "mitk-users@lists.sourceforge.net<mailto:mitk-users@lists.sourceforge.net>" 
<mitk-users@lists.sourceforge.net<mailto:mitk-users@lists.sourceforge.net>>
Betreff: RE: RE: [mitk-users] error LNK2019: unresolved external symbol
I guess in that case it is the MODULES line at the end. :)
(Please keep the conversation on the list so that others can benefit from it as 
well, thank you)

From: Sina Gerlach [mailto:sina.gerlac...@gmx.de]
Sent: Dienstag, 13. Oktober 2015 14:24
To: Kislinskiy, Stefan
Subject: Aw: RE: [mitk-users] error LNK2019: unresolved external symbol

Hi Stefan,
thanks for the fast response.
I'm not quite sure where to add that mentioned line.
This is what my cmakelists looks like:

project(AwesomeApp)
set(_app_options)
if(${MY_PROJECT_NAME}_SHOW_CONSOLE_WINDOW)
list(APPEND _app_options SHOW_CONSOLE)
endif()
# Plug-ins listed below will not be
# - added as a build-time dependency to the executable
# - listed in the provisioning file for the executable
# - installed if they are external plug-ins
set(_exclude_plugins
)
mitkFunctionCreateBlueBerryApplication(
NAME ${MY_APP_NAME}
DESCRIPTION "MITK - ${MY_APP_NAME} Application"
EXCLUDE_PLUGINS ${_exclude_plugins}
${_app_options}
)
mitk_use_modules(TARGET ${MY_APP_NAME}
MODULES MitkAppUtil
PACKAGES Qt4|QtGui Qt5|Widgets
)

Best
Sina
Gesendet: Dienstag, 13. Oktober 2015 um 14:00 Uhr
Von: "Kislinskiy, Stefan" 
<s.kislins...@dkfz-heidelberg.de<mailto:s.kislins...@dkfz-heidelberg.de>>
An: "Sina Gerlach" <sina.gerlac...@gmx.de<mailto:sina.gerlac...@gmx.de>>, 
"mitk-users@lists.sourceforge.net<mailto:mitk-users@lists.sourceforge.net>" 
<mitk-users@lists.sourceforge.net<mailto:mitk-users@lists.sourceforge.net>>
Betreff: RE: [mitk-users] error LNK2019: unresolved external symbol
Hi Sina,

it seems that the linker isn’t able to find mitk::DataNodeFactory, which is 
located in the MitkLegacyIO module. Add MitkLegacyIO to the DEPENDS line of 
your module CMakeLists.txt.

Best,
Stefan

From: Sina Gerlach 
[mailto:sina.gerlac...@gmx.de<sina.gerlac...@gmx.de><mailto:sina.gerlac...@gmx.de%3csina.gerlac...@gmx.de%3e>]
Sent: Dienstag, 13. Oktober 2015 12:27
To: mitk-users@lists.sourceforge.net<mailto:mitk-users@lists.sourceforge.net>
Subject: [mitk-users] error LNK2019: unresolved external symbol

Hello,

I am new to MITK and am trying to use the MITK Tutorial to display an image in 
my own Qt User Interface.

When trying to build my project the following error occurs:

7> Creating library C:/MITK-pt-sb/AwesomeProject-build/bin/Debug/AwesomeApp.lib 
and object C:/MITK-pt-sb/AwesomeProject-build/bin/Debug/AwesomeApp.exp
7>MainWindow.obj : error LNK2019: unresolved external symbol 
"__declspec(dllimport) public: static class itk::SmartPointer<class 
mitk::DataNodeFactory> __cdecl mitk::DataNodeFactory::New(void)" 
(__imp_?New@DataNodeFactory@mitk@@SA?AV?$SmartPointer@VDataNodeFactory@mitk@@@itk@@XZ)
 referenced in function "public: void __cdecl 
MainWindow::on_openButton_pressed(void)" 
(?on_openButton_pressed@MainWindow@@QEAAXXZ)


I know this is a linker problem but I dont know which library to link or what 
else has to be done to solve this error.

I hope anyone can help

Best Regards
Sina
------------------------------------------------------------------------------
_______________________________________________
mitk-users mailing list
mitk-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mitk-users

Reply via email to