2

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.

Community
  • 1
  • 1
the_naive
  • 2,936
  • 6
  • 39
  • 68

1 Answers1

1

The right way to specify library link locations in a .pro file is actually via the QMAKE_LIBDIR variable:

QMAKE_LIBDIR += "D:/dcmtk-3.6.0/Lib files/Release/"

Your issue above is almost certainly because of missing quotes (the space is being interpreted as a argument break and you need it to be one argument).

Wes Hardaker
  • 21,735
  • 2
  • 38
  • 69
  • Thanks, I haven't seen yours before I found a solution. But I have updated question with a solution include. :) – the_naive May 22 '13 at 13:48
  • But I'd like to ask you another question if you may know. If I want set several files together to ignore in `/NODEFAULTLIB` is there any way I can do it in one line? Or I have to do it in several line? – the_naive May 22 '13 at 13:53