I'm having a simple yet extremely annoying problem with adding the external library files in QtCreator. I'm adding them via the following lines in .pro
file:
INCLUDEPATH += $$quote(D:/dcmtk-3.6.0/Prefix Files/include)
LIBS += $$quote(-LD:/dcmtk-3.6.0/Lib files/Release/) \
-ladvapi32 \
-ldcmdata\
-loflog\
-lofstd\
-lws2_32\
-lnetapi32\
-lwsock32\
LIBS += $$quote(-LD:/dcmtk-3.6.0/Lib files/Debug/) \
-ladvapi32 \
-ldcmdata\
-loflog\
-lofstd\
-lws2_32\
-lnetapi32\
-lwsock32\
But every time it's giving the error :-1: error: LNK1181: cannot open input file 'files/Release).obj'
.
I know the problem is occuring because of the spaces there, despite trying to follow the documentation it doesn't seem to work. I also think that may be QtCreator doesn't update the changes I'm trying to make. Any suggestions please? Thanks.
EDIT WITH SOLVED ANSWER:
I changed the codes in .pro file to this:
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TEMPLATE = app
TARGET = NewApp
##QMAKE_CXXFLAGS_DEBUG += /MTd
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
DEFINES += _REENTRANT
QMAKE_CFLAGS_RELEASE -= -MD
QMAKE_CFLAGS_RELEASE = -MT
QMAKE_CFLAGS_DEBUG -= -MDd
QMAKE_CFLAGS_DEBUG = -MTd
QMAKE_CXXFLAGS_RELEASE -= -MD
QMAKE_CXXFLAGS_RELEASE += -MT
QMAKE_CXXFLAGS_DEBUG -= -MDd
QMAKE_CXXFLAGS_DEBUG += -MTd
QMAKE_LFLAGS_DEBUG += /NODEFAULTLIB:msvcrtd.lib
QMAKE_LFLAGS_RELEASE += /NODEFAULTLIB:msvcrt.lib
INCLUDEPATH += $$quote(D:/dcmtk-3.6.0/Prefix Files/include/)
CONFIG( debug, debug|release ) {
LIBS += $$quote(-LD:/dcmtk-3.6.0/LibFiles/Debug/) \
-ladvapi32\
-ldcmdata\
-loflog\
-lofstd\
-lws2_32\
-lnetapi32\
-lwsock32\
}
else {
LIBS += $$quote(-LD:/dcmtk-3.6.0/LibFiles/Release/) \
-ladvapi32\
-ldcmdata\
-loflog\
-lofstd\
-lws2_32\
-lnetapi32\
-lwsock32\
}
Here I had to add the lines:
QMAKE_LFLAGS_DEBUG += /NODEFAULTLIB:msvcrtd.lib
QMAKE_LFLAGS_RELEASE += /NODEFAULTLIB:msvcrt.lib
Because, if you turn on MT
, you must use /NODEFAULTLIB
switch to ignore these libraries: libc.lib, msvcrt.lib, libcd.lib, libcmtd.lib, msvcrtd.lib
, otherwise you will get link problem.
And I also found the answer to LIB
problems via this link where it's quoted:
"The normal
debug:LIBS += ...
else:LIBS += ...
solution breaks when users naively use CONFIG += debug
or CONFIG += release
to switch between debug and release builds (and they do; no-one remembers to say CONFIG -= release
release_and_debug before CONFIG += debug
:).
This is the canonical way to scope on debug:
CONFIG( debug, debug|release ) {
# debug
} else {
# release
}
"
Anyways, thanks a lot.