c++ - How can I add dcmtk libraries to QTCreator project? -
i'm new qtcreator. made small program using dcmtk libraries in visual studio, i'm trying make gui , doing i'm trying make same program in qtcreator can add gui feature. problem occurs when try add header files , .lib files qtcreator. when doing program in visual studio added following libraries libraries:
dcmdata.lib oflog.lib ofstd.lib ws2_32.lib netapi32.lib with library directory debug mode:
d:\dcmtk-3.6.0\lib files\debug; and release mode was
d:\dcmtk-3.6.0\lib files\release; for adding header files in visual studio put include directories as:
d:\dcmtk-3.6.0\prefix files\include; so, qtcreator in .pro file edited , added lib files , header file directories , pointed lib files need , .pro file looked following:
#------------------------------------------------- # # project created qtcreator 2013-05-02t10:59:41 # #------------------------------------------------- qt += core#adding core framework qt -= gui#removing gui portion target = untitled#targetting project config += console#defining console application config -= app_bundle# template = app sources += main.cpp#adding main.cpp 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, added names of header files using #include directive , code 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 gives error when try build it. error following:
d:\qtfiles\untitled\main.cpp:3: error: c1083: cannot open include file: '/dcmtk/config/osconfig.h': no such file or directory it seems made error while linking header files , lib files program. 2 lines in programming code
#include "dcmtk/config/osconfig.h" #include "dcmtk/dcmdata/dctk.h" doesn't give error in visual studio, i'm sure there's nothing wrong them. me mistake i'm doing in linking external header , lib files?
solution:
i changed lines in .pro file links external following , 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/"
- you forgot quotes in
includepath - you forgot
-lprefix before path inlibs - you forgot
\after path inlibs. - you should not use absolute pathes. if have to, extract variable.
- you should separate debug , release cases using
config(debug, debug|release)
so, project should like
qt = core target = untitled#targetting project config += console#defining 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 main.cpp 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
Comments
Post a Comment