Using external lib / dll in Qt Creator?

I decided after a bunch of headaches all morning that using Qt Creator for my first Qt project would probably be better than MSVC (there were too many problems compiling).

I am wondering how can I add the .dlls and .libs that I need for external tools through Qt Creator. I found this post Adding an external library to a Qt Creator project , which makes sense.

I need a little more information, for example ... How can I link dlls or libs in the first place, what is the syntax for adding dlls to the build phase in qmake (I assume it is close to win32: LIBS + = path / to / Psapi .lib)

Thank!

+3
source share
1

QtCreator/gcc

, .pro, (.dll .a) Framework ( Mac OS X):

TEMPLATE = lib

INCLUDEPATH = <your-include-paths>
HEADERS += <your-headers>
SOURCES += <your-sources>
TARGET = MyLib  /* The name of your libary */

/* Win32: To generate a MyLib.dll and libMyLib.a (gcc) or MyLib.lib (MSVC) file */
win32 {
    CONFIG += dll
}

/* Just in case you need to generate Mac Frameworks: */
macx {
    CONFIG += shared lib_bundle
    FRAMEWORK_HEADERS.version = Versions
    FRAMEWORK_HEADERS.files += <your library headers>
    /* Example:
    FRAMEWORK_HEADERS.files += /path/to/your/lib/MyLib.h
    */
    FRAMEWORK_HEADERS.path = Headers
    QMAKE_BUNDLE_DATA = FRAMEWORK_HEADERS
    VERSION = 0.5.0   // a framework version you can define
}

QtCreator/gcc

/* your project settings */

/* If you compile on windows */
win32 {
    /* If you compile with QtCreator/gcc: */
    win32-g++:LIBS += /path/to/your/libMyLib.a

    /* IF you compile with MSVC: */
    win32-msvc:LIBS += /path/to/your/libMyLib.lib
}

/* If compile on Mac and want to link against a framework */
macx {
    LIBS+= -framework MyLib
    QMAKE_FLAGS += -F/path/to/MyLib
}

, gcc libMyLib.a, . libMyLib.lib MS Visual Studio gcc afaik!

+13

Source: https://habr.com/ru/post/1767940/


All Articles