How to use clang 5 with qt in qt creator? - c++

I've configured my locally installed version of clang 5.
and set up a kit with it
but when I do a build with it:
it's clearly still using the system compiler for qmake, which causes a bunch of errors because my code requires C++17 support:
How do I set what compiler qmake is using?
Thank you.

You can do it in your pro file, directly:
QMAKE_CC = /path/to/the/c/compiler
QMAKE_CXX = /path/to/the/c++/compiler
but you'd be better specify the correct Qt mkspec in your kit, which could be something like linux-clang. Check the mkspecs directory, see if in some of its subdirectories there is the right qmake.conf already, if not you can make a new subdirectory in mkspecs and a new configuration file inside it. The mkspecs directory should be in the path given by the terminal command
qmake -query QT_INSTALL_ARCHDATA
Hope it helped.

Related

Using scons to compile C++ code under windows, scons adds "/Fo" as compile option

Using the following:
Python version 2.7.13, Scons version 2.5.1, Visual Studio 2012 express is installed, but I am not planning to use it.
Code blocks and MinGW-W64-builds-4.3 are installed.
Using Scons to compile C++ code (networkit toolkit) under windows. Scons adds "/Fo" as compile option. This option works only with VC++ and not with MinGW which I am trying to use. Why does Scons add this flag? I have checked my Sconstruct and the reference build.conf files and cannot seem to find this flag getting set explicitly.
My Sconstruct file is here(http://www103.zippyshare.com/v/jSrMapGz/file.html) and the build.conf file is here (http://www11.zippyshare.com/v/aXGQA5b5/file.html).
I want to get the compilation done with "-o" flag for g++, which is the equivalent of /Fo flag for VC++. I just cant figure out where Scons is picking this flag from :(
I am a novice with python and scons. I typically use VC++ 2012 but have to use networkit toolkit for a project, but it uses C11 features. And I cannot update to VC++ 2015/2017 yet.
Thanks for your help!
I checked your SConstruct file, and you are initialising your build environment as
env = Environment()
, which leaves the environment variable "tools" set to its standard value "default". The latter setting means: let SCons figure out which tools/compilers are installed in the current system, and add corresponding Builders to the build environment automatically. Under Windows, SCons will prefer "vc" over "mingw"...this is hardcoded at the moment (we're working on changing this for future versions of the core source).
What you can do, since you know that you have a "mingw" compiler installed that you want to use explicitly, is to tell SCons that you want to work with "mingw" only.
The following example from the page https://bitbucket.org/scons/scons/wiki/SconstructShortMingwWin32 shows the basic recipe for this:
import os
#don't use the default environment
DefaultEnvironment(tools=[])
#create an environment that uses mingw tools
env = Environment(ENV=os.environ, tools=['mingw'])
#the target will be myprogram.exe (in win32)
#the source files will be every file in the
#current directory that matches "*.cpp"
env.Program(target='myprogram', source = Glob('*.cpp'))
For further help and as reference, please consider checking out our User Guide and Man page.

Qt-GStreamer: PKGCONFIG not found

I am pretty new to setting the Qt Creator environment in Linux.
I will cross compile this demo program to the Yocto Project i.MX6. This demo program needs to use Qt-GStreamer
in demo.pro
There is these 2 lines
CONFIG += link_pkgconfig
PKGCONFIG += Qt5GLib-2.0 Qt5GStreamer-1.0 Qt5GStreamerUi-1.0 Qt5GStreamerUtils-1.0 Qt5GStreamerQuick-1.0
at compile in the Desktop, it shows
error: Qt5GLib-2.0 development package not found
This applies to all the other packages as well.
I know that it tells me that I am missing the package for the Qt Gstreamer.
However, when I look at this thread, the answer is
export PKG_CONFIG_LIBDIR=/home/anisha/Desktop/newGSTr/qt-gstreamer-0.10.3/lib/x86_64-linux-gnu/pkgconfig
But, from what I have downloaded in Qt Binding-GStreamer qt-gstreamer-0.10.3 Does not have the lib folder inside.
I have also used cmake to work with the CMakeList.txt inside the folder but encounter Qt missing packages error.
Could someone help me on setting up those packages?

How configure Qt Creator to compile qupzilla?

Is there any simple way to configure Qt Creator to compile qupzilla in my folder (not in /usr/bin and /usr/lib)?
By default i get "error: ../../bin/libQupZilla.so". If i set the path to my app folder with ldconfig - app is compiled but without plugins. They return errors for example (build/qrc_testplugin.cpp Error 1 or something with locale folder).
OS: Arch Linux 64 bit
QT: Qt5
Also i successfully compile qupzilla-git from AUR with qt5. This means that my problem somewhere in incorrect settings or paths...
Qupzilla: http://www.qupzilla.com/
Solution:
1) Add path to programm "path_to_app/bin" to ldconfig (/etc/ld.so.conf)
2) Check off in Projects "Shadow build" checkbox.
3) Change qmake to qmake-qt5. If I understand correctly, it is not necessary to do. Since in Arch Linux qmake and qmake-qt5 same.
4) In build environment add
KDE true
USE_WEBGL true
If you have libQupZilla (or any library) somewhere else than system library directories, easiest is to edit the .pro file, add line like:
LIBS += -L$(PWD)/..relative-path-to-library-location../
...or use absolute path to the library if you want. You probably already have -lQupZilla there, so no need to add that the 2nd time.
In general, with problems like this in Qt Creator, look at the Compile Output tab (at the bottom of the screen). Find the link command (note: if project uses cmake instead of qmake, you may need to add some switches or something for that to make the command visible), which is the one with all the -L/path and -lfoobar switches, and -o programname outputting the final target. Then look earlier to see in what directory it is being run in. Then look if everything matches, and possibly try to copy-paste and run the command from command line yourself, in the same directory where it is run when building under Qt Creator.

Qt unit-test: why "qmake" is not recognized

I managed to follow this tutorial in order to write my first unit-test.
However, when opening a "cmd-console" from inside my project folder and try to rum qmake, i get the following error:
'qmake' is not recognized as an internal or external command, operable program or batch file.
so, why qmake is not recognized? (note that I am working on windows Vita)
On Windows qt and its tools are installed by default in C:\Qt\blablah. You should add the path to the qmake binary, and that will do the trick. See the instructions here. Note that Qt creator set some variables for its terminal so you use qmake in creator without touching the system.
set path the Qt compiler.
sth like this:
set PATH=C:\Qt\4.8.5\bin
where the 4.8.5 is the version of Qt you installed.
If you don't want to add the QT bin path to PATH you can write the full path to qmake:
>"$(QTDIR)\bin\qmake.exe" -o Makefile odbc.pro
where $(QTDIR) is the full path of the qtbase directory.

Adding different compiler to QT

How can I add another compiler and use it with QT?
I'm asking because I couldn't find it anywhere on the web how to do it.
Thanks.
If you are using qmake, you can override the compiler used by the current mkspec with QMAKE_CXX, e.g. qmake QMAKE_CXX=g++-4.6.
To permanently override it, you'll need a new or edit the mkspec files. You can browse where they are with qmake -query and look at the QMAKE_MKSPECS variable. From there, the directory "default" is used if you do not use the -spec parameter in qmake. In that directory, the file qmake.conf will contain the mentioned QMAKE_CXX paramater that determines the compiler.
On MacOs, if you want to use gcc/g++ you can edit the Project (.pro) file to include (at the top):
QMAKE_CC = gcc
QMAKE_CXX = g++
Then run qmake against the Project file.