1

I'm very new to QTCreator. I made a small program using Dcmtk libraries in Visual studio, now I'm trying to make that with GUI and for doing so I'm trying to make the same program in QTCreator so that I can add that GUI feature. But the problem occurs when I try to add the header files and .lib files to QTCreator. When doing the program in Visual studio I added the following libraries libraries:

dcmdata.lib
oflog.lib
ofstd.lib
ws2_32.lib
netapi32.lib

with the library directory for debug mode:

D:\dcmtk-3.6.0\Lib files\Debug;

and for release mode was

D:\dcmtk-3.6.0\Lib files\Release;

For adding the header files in Visual Studio I put the include directories as:

D:\dcmtk-3.6.0\Prefix Files\include;

So, for QTCreator in the .pro file I edited and added the lib files and header file directories and pointed which lib files I need and the .pro file looked as the following:

#-------------------------------------------------
#
# Project created by QtCreator 2013-05-02T10:59:41
#
#-------------------------------------------------

QT       += core#adding the core framework

QT       -= gui#removing the gui portion

TARGET = untitled#targetting the project
CONFIG   += console#defining that it is console application
CONFIG   -= app_bundle#

TEMPLATE = app


SOURCES += main.cpp#adding the main.cpp as source file
LIBS +="D:/dcmtk-3.6.0/Lib files/Release"
-ldcmdata\
-loflog\
-lofstd\
-lws2_32\
-lnetapi32\
-wsock32\
LIBS +="D:/dcmtk-3.6.0/Lib files/Debug"
-ldcmdata\
-loflog\
-lofstd\
-lws2_32\
-lnetapi32\
-lwsock32\
INCLUDEPATH += "D:/dcmtk-3.6.0/Prefix Files/include"

I haven't begun programming yet, but I just added the names of header files using #include directive and the code is the following:

#include <QCoreApplication>
#include <QDebug>
#include "dcmtk/config/osconfig.h"
#include "dcmtk/dcmdata/dctk.h"
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    QString mystr="Hellow world";
    qDebug() <<mystr;
    return a.exec();
}

But this gives error when I try to build it. The error is the following:

D:\QtFiles\untitled\main.cpp:3: error: C1083: Cannot open include file: '/dcmtk/config/osconfig.h': No such file or directory

It seems I made some error while linking the header files and lib files to the program. The two lines in the programming code

#include "dcmtk/config/osconfig.h"
    #include "dcmtk/dcmdata/dctk.h"

doesn't give error in Visual Studio, so I'm sure there's nothing wrong with them. Could you say me what mistake I'm doing in linking the external header and lib files?

SOLUTION:

I changed the lines in .pro file that links the external to the following and it worked:

LIBS += -L"D:/dcmtk-3.6.0/Lib files/Release" \
-ldcmdata\
-loflog\
-lofstd\
-lws2_32\
-lnetapi32\
-lwsock32\

LIBS += -L"D:/dcmtk-3.6.0/Lib files/Debug" \
-ldcmdata\
-loflog\
-lofstd\
-lws2_32\
-lnetapi32\
-lwsock32\

INCLUDEPATH += "D:/dcmtk-3.6.0/Prefix Files/include/"
the_naive
  • 2,936
  • 6
  • 39
  • 68
  • `INCLUDEPATH *= ` *= looks strange. (And you're missing quotes on that line. Having spaces in the paths for includes or libs is a great way of wasting a whole lot of time fighting against various utilities that simply don't expect them.) – Mat May 03 '13 at 09:31
  • Actually I was just trying with that way, but even if I put INCLUDEPATH = it doesn't work. I've edited that part now. – the_naive May 03 '13 at 09:34
  • You're still missing quotes. (And should have been += rather than *=, but should be ok with just =). – Mat May 03 '13 at 09:40
  • Even after making it +=, build fails. The same error is there. – the_naive May 03 '13 at 09:48
  • I don't want to sound insistent, but _what about the quotes_? – Mat May 03 '13 at 09:48
  • Do you mean quotation mark? Do you mean I have to write something like this: INCLUDEPATH += "D:/dcmtk-3.6.0/Prefix Files/include" ? – the_naive May 03 '13 at 09:52
  • That's what you do in all the other places you have spaces in directory names. – Mat May 03 '13 at 09:54
  • Well, I did change to that as you said, but nothing changes :(. – the_naive May 03 '13 at 09:55
  • Did you try LIBS += -L"D:/dcmtk-3.6.0/Lib files/Release"? – thuga May 03 '13 at 10:14

1 Answers1

1
  1. You forgot quotes in INCLUDEPATH
  2. You forgot -L prefix before path in LIBS
  3. You forgot \ after path in LIBS.
  4. You should not use absolute pathes. If you have to, extract it to the variable.
  5. You should separate your debug and release cases using CONFIG(debug, debug|release)

So, your project should look like

QT       = core
TARGET = untitled#targetting the project
CONFIG   += console#defining that it is console application
CONFIG   -= app_bundle#
TEMPLATE = app
DCMTK="D:/dcmtk-3.6.0"

DCMTK_LIBS_PREFIX=$$DCMTK"/Lib files"
DCMTK_INCLUDE=$$DCMTK"/Prefix Files/include"
INCLUDEPATH+=$$DCMTK_INCLUDE

SOURCES += main.cpp#adding the main.cpp as source file

CONFIG(debug, debug|release) {
LIBS +=-L$$DCMTK_LIBS_PREFIX/Debug
} else {
LIBS +=-L$$DCMTK_LIBS_PREFIX/Release
}
LIBS+= -ldcmdata -loflog -lofstd -lws2_32 -lnetapi32 -wsock32
Lol4t0
  • 12,444
  • 4
  • 29
  • 65
  • I am trying to configure Qt Creator with DCMTK and I am getting the following error: "dcmtk/config/osconfig.h: No such file or directory". I've added your code to my .pro file and I am sure the files are in the right folder. How can I solve this problem? My .pro file: http://pastebin.com/h7gm4VxM. My main.cpp file: http://pastebin.com/zv8Tw3Qw – Engo Nov 09 '15 at 15:18
  • @Engo, make sure all your files are there. According to your config `osconfig.h` should be `C:/dcmtk-install/include/dcmtk/config/osconfig.h`. If it is not there, find it actual location and change your path accordingly – Lol4t0 Nov 09 '15 at 15:48
  • I am sure the file is there. When I press ctrl+ [the include] in the Qt Editor, it even opens osconfig.h :S – Engo Nov 09 '15 at 16:18
  • I have created a new question related to this question. Could you please take a look?http://stackoverflow.com/questions/33640835/how-to-get-the-dcmtk-library-working-in-qt-creator – Engo Nov 10 '15 at 22:36