Compiling external libraries with QtCreator/gcc
If you own the source code of your libraries this is the .pro file to make an external library (.dll and .a) or Framework (on Mac OS X) from them:
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
}
Adding external libraries to your QtCreator/gcc project
/* 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
}
Note that to use external libraries with gcc
you need the libMyLib.a file that contains the linking information. The libMyLib.lib
are generated by MS Visual Studio and can't be processed by gcc afaik!