Whiteha
Whiteha

Reputation: 93

How to build dll in Qt creator the same way as in Visual Studio?

I have a project of a DLL in the Visual Studio written on pure C++ and STL. I have to migrate to the Qt Creator for adding some of Qt features. For beginning I simply tried to do next steps: 1) Copy sources in a new folder 2) Manually make a .pro file with these sources 3) And add this preferences in .pro file:

  1. TEMPLATE = lib
  2. TARGET = LogonProvider
  3. DEFINES -= UNICODE
  4. DEFINES += LogonProvider_LIBRARY
  5. CONFIG += dll
  6. LIBS += -lsecur32 -ladvapi32 -luser32 -lole32 -lshlwapi
  7. #<...> There is list of sources

It all seems good and the project has compiled and I get DLL... but DLL doesn't work and have size about 30Kb, when have to have about 1Mb (if I built it with the Visual Studio) As I can understand, linker can't assembly .obj files to DLL, that's why it is reduced (as a result I have much .obj files around my DLL). But there were no errors or warnings during a linking proces in the Qt Creator. I think it is some of Qt options, but what can I do with it? How can I get the same DLL from Qt as from Visual Studio?

PS. Sorry for bad english

Upvotes: 2

Views: 4213

Answers (1)

jaho
jaho

Reputation: 5002

Do you actually add sources and headers to your .pro file?

There are two easy ways to achieve what you want. You can either create a new blank library project in Qt Creator (File > New File or Project > Libraries > C++ Library) which will setup the .pro file for you, and then add existing sources to the project. Or you can use Qt Visual Studio Add-in to generate the .pro file for you in Visual Studio.

For reference, here is a valid project file for a library:

QT       -= gui

TARGET = mylib
TEMPLATE = lib

DEFINES += MYLIB_LIBRARY

SOURCES += mylib.cpp

HEADERS += mylib.h\
        mylib_global.h

unix {
    target.path = /usr/lib
    INSTALLS += target
}

Upvotes: 1

Related Questions