DICOM @ OFFIS

Discussion Forum for OFFIS DICOM Tools - For registration, send email with desired user name to the OFFIS DICOM team
It is currently Fri, 2018-06-22, 21:20

All times are UTC + 1 hour




Post new topic Reply to topic  [ 23 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Fri, 2016-02-19, 09:05 
Offline

Joined: Fri, 2016-02-19, 08:51
Posts: 20
I have compiled DCMTK 3.6.0 with Visual Studio 2008 and trying to include it in Qt creator framework. However, when I try to compile the program I get the following error:

Quote:
error: undefined reference to `DicomImage::DicomImage(char const*, unsigned long, unsigned long, unsigned long)'


main.cpp:

Code:
#include "dcmtk/config/osconfig.h"
#include "dcmtk/dcmdata/dctk.h"
#include "dcmtk/dcmimgle/dcmimage.h"
#include "iostream"

int main(int argc, char *argv[])
{

    DicomImage *image = new DicomImage("test.dcm");
    if (image != NULL){
        std::cout << "hell yeah!";
    }

    return 0;
}


.pro file:

Code:
#-------------------------------------------------
#
# Project created by QtCreator 2016-02-18T19:16:51
#
#-------------------------------------------------

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = untitled1
TEMPLATE = app


SOURCES += main.cpp
        #mainwindow.cpp

#HEADERS  += mainwindow.h

#FORMS    += mainwindow.ui

#--------------------------------
CONFIG += c++11
#--------------------------------
LIBS += -L"C:\Program Files (x86)\DCMTK_1\lib"
LIBS +=-ldcmimgle -ldcmdata -loflog -lofstd

win32:LIBS += -lAdvAPI32 -lofstd -loflog -ldcmdata -ldcmnet -ldcmimage -ldcmimgle -lWS2_32 -lNetAPI32 -lWSock32
INCLUDEPATH += "C:\Program Files (x86)\DCMTK_1\include"


I also copied libraries AdvAPI32, WS2_32, NetAPI32 and WSock32 to DCMTK lib folder from Windows SDK folder. I think I have the correct order of libraries as was stated in FAQ #27, however I can't make it work in anyway. What is the problem? I'm using Windows 7 x64.


Top
 Profile  
 
PostPosted: Fri, 2016-02-19, 10:23 
Offline
DCMTK Developer

Joined: Tue, 2011-05-03, 14:38
Posts: 1939
Location: Oldenburg, Germany
Not sure whether the "LIBS" or "win32:LIBS" line of your .pro file is actually used, but the order of libraries in "win32:LIBS" seems to be wrong: first dcmimgle, then dcmimage. You could also try to omit "dcmimage" since you did not register support for color images in your sample program.


Top
 Profile  
 
PostPosted: Fri, 2016-02-19, 11:44 
Offline

Joined: Fri, 2016-02-19, 08:51
Posts: 20
I have tried everything you said and still doesn't work. Now I only have these two lines in my .pro file:

Code:
INCLUDEPATH += C:/DCMTK/include

LIBS += -L"C:/DCMTK/lib" -lAdvAPI32 -ldcmimgle -ldcmdata -loflog -lofstd -lWS2_32 -lNetAPI32 -lWSock32


I have also tried to remove the LIBS line at all and the effect was the same - looks like it completely doesn't include those lib files.

The tree of the compiled version of dcmtk looks like:

Image
http://imgur.com/YRDjA02

Maybe I have compiled it wrongly? I used Visual Studio 2008 and build for DEBUG and win32.


Top
 Profile  
 
PostPosted: Fri, 2016-02-19, 13:06 
Offline
DCMTK Developer

Joined: Tue, 2011-05-03, 14:38
Posts: 1939
Location: Oldenburg, Germany
Enabling the verbose mode of the linker should give you more details...


Top
 Profile  
 
PostPosted: Fri, 2016-02-19, 14:58 
Offline

Joined: Fri, 2016-02-19, 08:51
Posts: 20
Sorry for stupid question but where should I enable it? In Qt creator?


Top
 Profile  
 
PostPosted: Fri, 2016-02-19, 15:28 
Offline
DCMTK Developer

Joined: Tue, 2011-05-03, 14:38
Posts: 1939
Location: Oldenburg, Germany
I would do this in "Visual Studio 2008" (see documentation).


Top
 Profile  
 
PostPosted: Fri, 2016-02-19, 17:52 
Offline

Joined: Fri, 2016-02-19, 08:51
Posts: 20
I enabled detailed verbose mode however it doesn't provide neither errors nor warnings. Everything builds successfully.


Top
 Profile  
 
PostPosted: Fri, 2016-02-19, 17:58 
Offline
DCMTK Developer

Joined: Tue, 2011-05-03, 14:38
Posts: 1939
Location: Oldenburg, Germany
That means, problem solved?


Top
 Profile  
 
PostPosted: Fri, 2016-02-19, 18:11 
Offline

Joined: Fri, 2016-02-19, 08:51
Posts: 20
Perhaps means that dcmtk libraries are build successfully but still I cannot make it work in Qt creator.


Top
 Profile  
 
PostPosted: Fri, 2016-02-19, 18:14 
Offline
DCMTK Developer

Joined: Tue, 2011-05-03, 14:38
Posts: 1939
Location: Oldenburg, Germany
Can't you enable the verbose linker output in "Qt creator", i.e. when linking the DCMTK libraries to your program?

Maybe, you can find the answer here: http://doc.qt.io/qtcreator/creator-build-settings.html


Top
 Profile  
 
PostPosted: Fri, 2016-02-19, 18:23 
Offline

Joined: Fri, 2016-02-19, 08:51
Posts: 20
I have just tried to execute the example app provided in FAQ #40 with Visual Studio 2008.

I got the following errors:

Code:
1>------ Build started: Project: testapp, Configuration: Debug Win32 ------
1>Compiling...
1>Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86
1>Copyright (C) Microsoft Corporation.  All rights reserved.
1>cl /Od /I "C:\DCMTK\include" /D "_REENTRANT" /D "CMAKE_INTDIR=\"Debug\"" /D "_MBCS" /FD /EHsc /MTd /Gy /Fo"testapp.dir\Debug\\" /Fd"testapp.dir\Debug\vc90.pdb" /W3 /c /Z7 /TP   /YX
1>   ..\testapp\testapp.cxx
1>cl : Command line warning D9002 : ignoring unknown option '/YX'
1>testapp.cxx
1>C:\DCMTK\include\dcmtk/ofstd/offile.h(200) : error C2039: 'popen' : is not a member of '`global namespace''
1>C:\DCMTK\include\dcmtk/ofstd/offile.h(200) : error C2440: '=' : cannot convert from 'bool' to 'FILE *'
1>        Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
1>C:\DCMTK\include\dcmtk/ofstd/offile.h(262) : error C2039: 'pclose' : is not a member of '`global namespace''
1>C:\DCMTK\include\dcmtk/ofstd/offile.h(262) : error C2660: 'OFFile::pclose' : function does not take 1 arguments
1>..\testapp\testapp.cxx(11) : error C2065: 'DCM_PatientsName' : undeclared identifier
1>..\testapp\testapp.cxx(11) : error C2228: left of '.good' must have class/struct/union
1>..\testapp\testapp.cxx(13) : error C2065: 'cout' : undeclared identifier
1>..\testapp\testapp.cxx(13) : error C2065: 'endl' : undeclared identifier
1>..\testapp\testapp.cxx(15) : error C2065: 'cerr' : undeclared identifier
1>..\testapp\testapp.cxx(15) : error C2065: 'endl' : undeclared identifier
1>..\testapp\testapp.cxx(17) : error C2065: 'cerr' : undeclared identifier
1>..\testapp\testapp.cxx(17) : error C2065: 'endl' : undeclared identifier
1>Build log was saved at "file://c:\Users\Donn\Desktop\install\testapp.dir\Debug\BuildLog.htm"
1>testapp - 12 error(s), 1 warning(s)
========== Build: 0 succeeded, 1 failed, 2 up-to-date, 0 skipped ==========


Do not know where to start from in order to solve it...


Top
 Profile  
 
PostPosted: Fri, 2016-02-19, 18:26 
Offline
DCMTK Developer

Joined: Tue, 2011-05-03, 14:38
Posts: 1939
Location: Oldenburg, Germany
The FAQ #40 entry refers to DCMTK 3.5.4, which is more than 10 years old.

What about FAQ #47: "How do I use the latest (snapshot) DCMTK libraries in my own application? [MSVC]"
However, be warned that "Visual Studio 2008" does not seem to be checked by the listed CMake file...

I guess the preferred way of using DCMTK in your own program (with support of CMake) is the one described here: http://support.dcmtk.org/redmine/projec ... akeExports


Last edited by J. Riesmeier on Fri, 2016-02-19, 18:40, edited 2 times in total.

Top
 Profile  
 
PostPosted: Fri, 2016-02-19, 18:35 
Offline

Joined: Fri, 2016-02-19, 08:51
Posts: 20
Actually only the Visual Studio 2008 provided me compilation of libraries without any errors or warnings. The versions of 2010, 2013 or later yields some errors and warnings. I will try to run snapshot version with VS2015.


Top
 Profile  
 
PostPosted: Fri, 2016-02-19, 18:37 
Offline
DCMTK Developer

Joined: Tue, 2011-05-03, 14:38
Posts: 1939
Location: Oldenburg, Germany
DCMTK 3.6.0 should work with VisualStudio 2010 (32-bit mode), as this compiler is listed in the INSTALL file.

But since this DCMTK release is already more than 5 years old, I would also recommend to use the latest development snapshot (from this week).


Top
 Profile  
 
PostPosted: Fri, 2016-02-19, 20:04 
Offline

Joined: Fri, 2016-02-19, 08:51
Posts: 20
Tried snapshot with VS15 and building the example you provided received many errors like:

Code:
2>------ Build started: Project: testapp, Configuration: Debug Win32 ------
2>Build started 2/19/2016 9:02:41 PM.
2>     1>
2>PrepareForBuild:
2>         Creating directory "testapp.dir\Debug\testapp.tlog\".
2>       InitializeBuildStatus:
2>         Creating "testapp.dir\Debug\testapp.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
2>       CustomBuild:
2>         Building Custom Rule C:/Users/Donn/Desktop/testapp/CMakeLists.txt
2>         CMake does not need to re-run because C:\Users\Donn\Desktop\install\CMakeFiles\generate.stamp is up-to-date.
2>       ClCompile:
2>         Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23506 for x86
2>         Copyright (C) Microsoft Corporation.  All rights reserved.
2>
2>         cl /c /IC:\DCMTK\include /Zi /W3 /WX- /Od /Ob0 /Oy- /D WIN32 /D _WINDOWS /D _DEBUG /D _REENTRANT /D "CMAKE_INTDIR=\"Debug\"" /D _MBCS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /GR /Fo"testapp.dir\Debug\\" /Fd"testapp.dir\Debug\vc140.pdb" /Gd /TP /analyze- /errorReport:prompt C:\Users\Donn\Desktop\testapp\testapp.cxx
2>
2>         testapp.cxx
2>       Link:
2>         Microsoft (R) Incremental Linker Version 14.00.23506.0
2>         Copyright (C) Microsoft Corporation.  All rights reserved.
2>
2>         "/OUT:C:\Users\Donn\Desktop\install\Debug\testapp.exe" /INCREMENTAL /LIBPATH:C:/DCMTK/lib /LIBPATH:C:/DCMTK/lib/Debug kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib dcmdata.lib oflog.lib ofstd.lib ws2_32.lib netapi32.lib wsock32.lib /MANIFEST "/MANIFESTUAC:level='asInvoker' uiAccess='false'" /manifest:embed /DEBUG "/PDB:C:/Users/Donn/Desktop/install/Debug/testapp.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT "/IMPLIB:C:/Users/Donn/Desktop/install/Debug/testapp.lib" /MACHINE:X86 /SAFESEH /machine:X86 /debug testapp.dir\Debug\testapp.obj
2>     1>
2>dcmdata.lib(dcitem.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in testapp.obj
2>     1>
2>dcmdata.lib(dcfilefo.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in testapp.obj
2>     1>
2>dcmdata.lib(dcvr.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in testapp.obj
2>     1>
2>dcmdata.lib(dcxfer.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in testapp.obj
2>     1>
2>dcmdata.lib(dctagkey.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in testapp.obj
2>     1>
2>dcmdata.lib(dctag.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in testapp.obj
2>     1>
2>dcmdata.lib(dcstack.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in testapp.obj
2>     1>
2>dcmdata.lib(dcobject.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in testapp.obj
2>     1>


Also, compiling dcmtk libraries received multiple warnings.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 23 posts ]  Go to page 1, 2  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group