QT Visual studio tools always creates x86 Qt project - visual-studio

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.

Related

including protobuf3 headers in Qt project on Mac

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 to install OpenCV with Visual Studio 2012 (64 bit) on Windows 7?

I'm following this guide to install OpenCV for Qt: http://www.laganiere.name/opencvCookbook/chap1s1_2.shtml. But this tutorial is made for Qt with mingw32 compiler kit.
Kindly suggest me the steps to install it on Visual Studio 2012 on Windows 7 64bit (with or without cmake).
You need to select your compiler not MinGW.
You then specify the compilers that will generate the project. In our case, they are the compilers of MinGW installed by default by Qt.
You need to select 64 bit Visual Studio 11.0. And when you finish configuration and click generate button cmake is going to generate you a solution file, all you need to do is open that solution file and compile it.
Use this guide http://docs.opencv.org/doc/tutorials/introduction/windows_install/windows_install.html. If you will have problems with building Qt 5.x, use Qt 4.x - it's much easier to build it.
Ok, I was able to solve this problem by following the guide mentioned by cyriel:http://docs.opencv.org/doc/tutorials/introduction/windows_install/windows_install.html.
And adding following lines to myproject.pro file:
INCLUDEPATH += C:\OpenCV\build\include
LIBS += C:\OpenCV\build\x64\vc11\lib\opencv_core244.lib
LIBS += C:\OpenCV\build\x64\vc11\lib\opencv_highgui244.lib
LIBS += C:\OpenCV\build\x64\vc11\lib\opencv_imgproc244.lib
LIBS += C:\OpenCV\build\x64\vc11\lib\opencv_calib3d244.lib
LIBS += C:\OpenCV\build\x64\vc11\lib\opencv_calib3d244d.lib
LIBS += C:\OpenCV\build\x64\vc11\lib\opencv_contrib244d.lib
LIBS += C:\OpenCV\build\x64\vc11\lib\opencv_core244d.lib
LIBS += C:\OpenCV\build\x64\vc11\lib\opencv_features2d244d.lib
LIBS += C:\OpenCV\build\x64\vc11\lib\opencv_flann244d.lib
LIBS += C:\OpenCV\build\x64\vc11\lib\opencv_gpu244d.lib
LIBS += C:\OpenCV\build\x64\vc11\lib\opencv_highgui244d.lib
LIBS += C:\OpenCV\build\x64\vc11\lib\opencv_imgproc244d.lib
LIBS += C:\OpenCV\build\x64\vc11\lib\opencv_legacy244d.lib
LIBS += C:\OpenCV\build\x64\vc11\lib\opencv_ml244d.lib
LIBS += C:\OpenCV\build\x64\vc11\lib\opencv_nonfree244d.lib
LIBS += C:\OpenCV\build\x64\vc11\lib\opencv_objdetect244d.lib
LIBS += C:\OpenCV\build\x64\vc11\lib\opencv_photo244d.lib
LIBS += C:\OpenCV\build\x64\vc11\lib\opencv_stitching244d.lib
LIBS += C:\OpenCV\build\x64\vc11\lib\opencv_ts244d.lib
LIBS += C:\OpenCV\build\x64\vc11\lib\opencv_video244d.lib
LIBS += C:\OpenCV\build\x64\vc11\lib\opencv_videostab244d.lib
By doing this, there is no need for additional compilation again by vsc2012. It also saves hard disk space. And anyone will be able to run their opencv project written in Qt5.1.

Compiling google test framework with Mingw compiler

I have a Qt project and i wanted to use google tests framework GoogleTestFramework in order to do google test. The framework compiled fine on Linux.
I have managed to compile the libraries on windows, using tips provided in the following link:
Installing Gtest without pthreads
The following advice do not let me compile the libraries, because of errors due to pthreads:
Sackoverflow compiling with MSYS
I have :
GNU Make 3.81 for make.exe
GNU Make 3.82 for mingw32-make
CMake 2.8.7
QT 4.7.4
Qt MingW gcc v 4.4.0
When i try to compile my test projet, i get an error saying:
undefined reference to '__chkstk_ms'
File not found: gtest-all.cc
Here is my qmake project code (I have semplified the code).
QT += core gui
DEPENDPATH += . headers src ../FastTrans/headers ../FastTrans/src ../FastTrans/forms C:/MinGW/msys/1.0/home/zakharan/gtest-1.6.0/include
INCLUDEPATH += . headers src ../FastTrans/headers ../FastTrans/src ../FastTrans/forms C:/MinGW/msys/1.0/home/zakharan/gtest-1.6.0/include
TARGET = tstall
#CONFIG += console
#CONFIG -= app_bundle
TEMPLATE = app
HEADERS += ../FastTrans/headers/shortcutsactionsitem.h \
../FastTrans/headers/shortcutsactionsmodel.h \
../FastTrans/headers/isavesettings.h
SOURCES += ../FastTrans/src/shortcutsactionsitem.cpp \
../FastTrans/src/shortcutsactionsmodel.cpp \
../FastTrans/src/isavesettings.cpp \
src/tstshortcutsactionsitem.cpp \
src/tstshortcutsactionmodel.cpp
INCLUDEPATH += $$PWD/
DEPENDPATH += $$PWD/
win32: LIBS += C:/MinGW/msys/1.0/home/zakharan/gtest-1.6.0/mybuid/libgtest.a
win32: LIBS += C:/MinGW/msys/1.0/home/zakharan/gtest-1.6.0/mybuid/libgtest_main.a
Google recommends the following for compiling in Windows:
### Windows Requirements ###
* Microsoft Visual C++ 7.1 or newer
### Cygwin Requirements ###
* Cygwin 1.5.25-14 or newer
I've heard of some people using MingW for compiling this. Supposedly compiling with MingW can be a little faster because there doesn't need to be a comparability layer between the OS and the application.
But, since this is just for dev testing purposes Cygwin should suffice. Just download the version that Google recommends.
See Also:
Compile Cygwin project in Eclipse
How Cygwin compares to MingW for porting Linux applications to Windows

How do I make apps smaller with qmake and macdeployqt

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.

qt in windows7 environment

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.

Resources