How do I build a static library and executable with Qt?

Filesystem layout: MyProject |_ myproject.pro |_ core |_ core.cpp |_ core.h |_ core.pro |_ app |_ main.cpp |_ app.pro myproject.pro: TEMPLATE = subdirs CONFIG += ordered SUBDIRS = core \ app app.depends = core core.pro: TEMPLATE = lib CONFIG += staticlib HEADERS = core.h SOURCES = core.cpp app.pro: TEMPLATE = app SOURCES = main.cpp LIBS … Read more

How to copy Qt runtime DLLs to project output

OK, here’s an ugly hack: # Copy required DLLs to output directory CONFIG(debug, debug|release) { QtCored4.commands = copy /Y %QTDIR%\\bin\\QtCored4.dll debug QtCored4.target = debug/QtCored4.dll QtGuid4.commands = copy /Y %QTDIR%\\bin\\QtGuid4.dll debug QtGuid4.target = debug/QtGuid4.dll QMAKE_EXTRA_TARGETS += QtCored4 QtGuid4 PRE_TARGETDEPS += debug/QtCored4.dll debug/QtGuid4.dll } else:CONFIG(release, debug|release) { QtCore4.commands = copy /Y %QTDIR%\\bin\\QtCore4.dll release QtCore4.target = release/QtCore4.dll QtGui4.commands … Read more

Build Qt in “Release with Debug Info” mode?

Old question, I know. But nowadays, you can simply use CONFIG += force_debug_info to get debug symbols even in release mode. When you use QMake via the command line, I usually do this to get a release build with debug info: qmake CONFIG+=release CONFIG+=force_debug_info path/to/sources this will enable below conditions of Qt5/mkspecs/features/default_post.prf: force_debug_info|debug: CONFIG += … Read more

How do I use qmake to build multiple binaries in a single project?

One way of doing it is to have a .pro file per subdirectory. appsuite.pro: TEMPLATE = subdirs SUBDIRS = common app1 app2 app3 app1.depends = common app2.depends = common app3.depends = common app1/app1.pro: TARGET = app1 SOURCES = main.cpp INCLUDEPATH += ../common LIBS += -L../common -lcommon The common.pro file should build a static library you … Read more

Copy a file to build directory after compiling project with Qt

The selected answer is correct but it requires to call make install, which in my opinion is annoying or error prone. Instead, to copy files to the build directory use: copydata.commands = $(COPY_DIR) $$PWD/required_files $$OUT_PWD first.depends = $(first) copydata export(first.depends) export(copydata.commands) QMAKE_EXTRA_TARGETS += first copydata Where required_files must be replaced with your correct path. $$PWD … Read more

How to convert qmake to cmake?

QMake: The required libraries. QT += core QT -= gui QT += network CMake: only the add is necessary. An exclude (QT -= gui) is not required. find_package(Qt5Core REQUIRED) find_package(Qt5Network REQUIRED) QMake: Additional Compiler flags: CONFIG += c++11 CMake: Extend the list of compiler flags as required. set(CMAKE_CXX_FLAGS “${CMAKE_CXX_FLAGS} -std=c++0x”) QMake: The source files SOURCES … Read more

How to convert qmake to cmake?

QMake: The required libraries. QT += core QT -= gui QT += network CMake: only the add is necessary. An exclude (QT -= gui) is not required. find_package(Qt5Core REQUIRED) find_package(Qt5Network REQUIRED) QMake: Additional Compiler flags: CONFIG += c++11 CMake: Extend the list of compiler flags as required. set(CMAKE_CXX_FLAGS “${CMAKE_CXX_FLAGS} -std=c++0x”) QMake: The source files SOURCES … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)