I am having a problem with running an example from qt which uses win32 libraries. When I compile I don't get any errors but when I run it is not able to open the application (.exe) file in Windows 7. But when I compile this example in WindowsXP it works fine. Can anyone let me know whether I need to change my .pro file in order to get it worked under Windows 7?
Here is my .pro file:
# -------------------------------------------------
# Project created by QtCreator 2010-04-16T11:45:43
# -------------------------------------------------
QT += network
QT += xml
QT += opengl
TARGET = Application
TEMPLATE = app
SOURCES += main.cpp \
mainwindow.cpp \
Tools.cpp \
Objects.cpp
HEADERS += mainwindow.h \
Tools.h\
Objects.h
unix {
OBJECTS_DIR = .obj
MOC_DIR = .moc
}
# UNIX installation
isEmpty(PREFIX):PREFIX = /usr/local
unix {
headers.path = $$PREFIX/include/ZIP
headers.files = $$HEADERS
target.path = $$PREFIX/lib
INSTALLS += headers \
target
}
!mac:x11:LIBS += -ldns_sd
win32:LIBS += -ldnssd
LIBPATH = C:/Temp/mDNSResponder-107.6/mDNSWindows/DLL/Debug
INCLUDEPATH += c:/Temp/mDNSResponder-107.6/mDNSShared
You can use Dependency Walker to help you find out what Qt DLLs are needed and copy them to the same folder as the .exe.
Your problem is probably because Windows can't find the Qt libraries.
Try placing the required Qt libraries (for instance QtNetwork4.dll, etc...) in the same directory as your .exe and see if it works.
Related
I have Qt Creator project. Every time I open the pro file from Qt VS tools, I only get x86 project. In Qt options, I have two compilers, x86 and x64 compiler (default). Even using x64 default compiler produces x86 project.
My project pro file looks like this.
TEMPLATE = app
TARGET = myApp
QT += qml quick core
CONFIG += c++11
HEADERS += main.h
SOURCES += main.cpp
RESOURCES += qml.qrc
# Default rules for deployment.
include(deployment.pri)
INCLUDEPATH += include \
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\windows.h\
MAKE_SPEC = $$split(QMAKESPEC, /)
contains(MAKE_SPEC, msvc2017_64):{
LIBS += -L"$$PWD/lib/x64" -lftd2xx
} else {
LIBS += -L"$$PWD/lib/x86" -lftd2xx
}
DISTFILES += deployment.pri \
lib/ftd2xx.lib \
ui/main.qml
SUBDIRS += myapp.pro
DESTDIR = bin
The platform is selected according to the current default Qt version (Qt VS Tools > Options > Default Qt/Win version). If an x64 Qt build is selected, new projects will be configured with the x64 platform.
I'm trying to run lupdate on my .pro file and this is what I see. Nothing happens next and .ts files aren't created. My OS is Win10 as seen from picture. I'm using Qt 5.10.1 with MinGW. Also I've tried to run lupdate on Ubuntu 16.04 and it seems that it works properly. Can somebody please help me with this issue?
QT += quick
QT += quickcontrols2
CONFIG += c++11
CONFIG += console
# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS QT_MESSAGELOGCONTEXT
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += main.cpp \
shoppinglistmodel.cpp \
loggingcategories.cpp \
logger.cpp \
purchase.cpp
RESOURCES += qml.qrc
# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =
# Additional import path used to resolve QML modules just for Qt Quick Designer
QML_DESIGNER_IMPORT_PATH =
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
HEADERS += \
shoppinglistmodel.h \
loggingcategories.h \
logger.h \
purchase.h
INCLUDEPATH += "C:\boost_1_66_0"
DISTFILES +=
TRANSLATIONS = sh_lst_ru.ts \
sh_lst_ua.ts
Solution: It seems that if you are using boost libraries in project that should be translated you have to involve TR_EXCLUDE option in your .pro file.
Here's the one from mine, maybe it will help somebody:
TR_EXCLUDE = C:\boost_1_66_0\*
as the title indicates, I am trying to compile a simple project in Qt that makes use of the addressbook.pb.h/addressbook.pb.cc files that are generated in the google protobuf3 tutorial for C++ users. Here is my .pro file
#-------------------------------------------------
#
# Project created by QtCreator 2016-11-07T10:33:12
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = prototest
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp \
../protobuf/examples/addressbook.pb.cc
HEADERS += mainwindow.h \
../protobuf/examples/addressbook.pb.h
FORMS += mainwindow.ui
INCLUDEPATH += /usr/local/Cellar/protobuf/3.1.0/include
LIBS += /usr/local/Cellar/protobuf/3.1.0
Unfortunately, this throws
:-1: error: can't map file, errno=22 file '/usr/local/Cellar/protobuf/3.1.0' for architecture x86_64
I'm stuck at this point. Any help would be greatly appreciated. I have been able to compile and run the exact same (addressbook.*) files using Xcode8.
Solved it: Add the following to the .pro file
macx: LIBS += -L$$PWD/../../../usr/local/Cellar/protobuf/3.1.0/lib/ -lprotobuf.11
INCLUDEPATH += $$PWD/../../../usr/local/Cellar/protobuf/3.1.0/include
DEPENDPATH += $$PWD/../../../usr/local/Cellar/protobuf/3.1.0/include
I should add how I arrived at this answer. Right click your project and select "Add Library->External Library", select your platform and enter your specific library (not path) that you want to add, and your include path (the options it gives you indicate such). Qt will generate the code and automatically add it to your .pro file.
How do I make apps smaller with qmake and macdeployqt?
I have set QT = core gui in the projects .pro file and run qmake and macdeployqt on the resulting app.
The problem is that the program is bundling QtNetwork, QtScript, QtSvg etc. I've tried setting QT -= network script svg (and then make clean, rm -rf *.app, qmake, make).
In total the app is 32 MB.
.pro file:
TEMPLATE = app
TARGET = throw
DEPENDPATH += .
INCLUDEPATH += .
CONFIG += x86_64 release
QT = core gui
unix {
CONFIG += link_pkgconfig
PKGCONFIG += glib-2.0
}
# Input
SOURCES += main.cpp
# Headers
HEADERS += throw.h
RESOURCES += throw.qrc
ICON = throw.png
mac {
QMAKE_INFO_PLIST = Info.plist
ICON = throw.icns
}
This is a great article about (re)building Qt statically and dynamically to reduce its size considerably: Building Qt Static (and Dynamic) and Making it Small with GCC, Microsoft Visual Studio, and the Intel Compiler
While this is talking about Qt in the windows context, it does give some good insight into how one would go about compiling for minimal size.
You could strip the binary afterwards in a post-build step. The Qt libraries themselves are shared by default.
I hm having a hard time integrating opencv with qt on xcode. If anyone has an example of working copy that would be great. Thanks.
Here is my example which works great with a classic installation of OpenCV (apt-get or opencv wiki install) on Linux / Mac.
TEMPLATE = app
TARGET = BIN/appName
QT += core \
xml
INCLUDEPATH += INC/folder/ \
INC/otherFoled/
HEADERS += INC/folder/.h \
INC/otherFoled/.h
SOURCES += SRC-BIN/main.cpp
SOURCES += SRC-LIB/folder/*.cpp
MOC_DIR += LIB/
OBJECTS_DIR += OBJ/
CONFIG += link_pkgconfig
PKGCONFIG += opencv
Good luck !