Discussion:
[Qt-creator] how can i use clang-cl with qt creator under Windows?
Dennis Luehring
2018-03-07 19:17:08 UTC
Permalink
my current setup is

QtCreator 4.4.1 (or 4.5 if needed), Qbs, Qt 5.6x and Visual Studio 2015
as my C/C++ x64 Compiler

my project can be compiled, linked, debugged - everything is working

an after reading the news about google using clang-cl for building
Chrome for the windows platform

http://blog.llvm.org/2018/03/clang-is-now-used-to-build-chrome-for.html

and want to give it a try - but how?

i've installed the x86 and x64 build of clang-cl from
http://llvm.org/builds/

and QtCreator finds the x64 clang-cl unter Options/Tools/...

Clang based on MSVC 2015 C++ - but nothing for the C compiler

when i change the C++ compiler in my current used kit to the found clang

it will fail finding cl.exe (its called clang-cl.exe) in the llvm folder
when i start to compiler

any ideas?
Eike Ziller
2018-03-08 06:22:46 UTC
Permalink
Post by Dennis Luehring
my current setup is
QtCreator 4.4.1 (or 4.5 if needed), Qbs, Qt 5.6x and Visual Studio 2015 as my C/C++ x64 Compiler
my project can be compiled, linked, debugged - everything is working
an after reading the news about google using clang-cl for building Chrome for the windows platform
http://blog.llvm.org/2018/03/clang-is-now-used-to-build-chrome-for.html
and want to give it a try - but how?
i've installed the x86 and x64 build of clang-cl from http://llvm.org/builds/
and QtCreator finds the x64 clang-cl unter Options/Tools/...
Clang based on MSVC 2015 C++ - but nothing for the C compiler
when i change the C++ compiler in my current used kit to the found clang
it will fail finding cl.exe (its called clang-cl.exe) in the llvm folder when i start to compiler
any ideas?
Check if the qmake step in your build configuration includes “-spec win32-clang-msvc”. If not, then set “win32-clang-msvc” in the “Qt mkspec” setting for your kit and try again. I suppose Qt Creator might not do that automatically in your case.

Br, Eike

--
Eike Ziller
Principal Software Engineer

The Qt Company GmbH
Rudower Chaussee 13
D-12489 Berlin
***@qt.io
http://qt.io
Geschäftsführer: Mika Pälsi,
Juha Varelius, Mika Harjuaho
Sitz der Gesellschaft: Berlin, Registergericht: Amtsgericht Charlottenburg, HRB 144331 B
Eike Ziller
2018-03-08 06:29:46 UTC
Permalink
Post by Eike Ziller
Post by Dennis Luehring
my current setup is
QtCreator 4.4.1 (or 4.5 if needed), Qbs, Qt 5.6x and Visual Studio 2015 as my C/C++ x64 Compiler
my project can be compiled, linked, debugged - everything is working
an after reading the news about google using clang-cl for building Chrome for the windows platform
http://blog.llvm.org/2018/03/clang-is-now-used-to-build-chrome-for.html
and want to give it a try - but how?
i've installed the x86 and x64 build of clang-cl from http://llvm.org/builds/
and QtCreator finds the x64 clang-cl unter Options/Tools/...
Clang based on MSVC 2015 C++ - but nothing for the C compiler
when i change the C++ compiler in my current used kit to the found clang
it will fail finding cl.exe (its called clang-cl.exe) in the llvm folder when i start to compiler
any ideas?
Check if the qmake step in your build configuration includes “-spec win32-clang-msvc”. If not, then set “win32-clang-msvc” in the “Qt mkspec” setting for your kit and try again. I suppose Qt Creator might not do that automatically in your case.
And you need Qt 5.8 or later for that.

QMake defines in its “mkspecs” which compiler to use. That’s why the mkspec is important. Qt Creator tries to set the correct mkspec automatically for some common cases based on the compiler you set in the kit, but it can’t do it for all cases.

Qt 5.6 doesn’t have a mkspec for clang-cl, so you need to either create one yourself, copy one from somewhere else (they are usually not self-contained though), or use a Qt version which has one.
Post by Eike Ziller
Br, Eike
--
Eike Ziller
Principal Software Engineer
The Qt Company GmbH
Rudower Chaussee 13
D-12489 Berlin
http://qt.io
Geschäftsführer: Mika Pälsi,
Juha Varelius, Mika Harjuaho
Sitz der Gesellschaft: Berlin, Registergericht: Amtsgericht Charlottenburg, HRB 144331 B
_______________________________________________
Qt-creator mailing list
http://lists.qt-project.org/mailman/listinfo/qt-creator
--
Eike Ziller
Principal Software Engineer

The Qt Company GmbH
Rudower Chaussee 13
D-12489 Berlin
***@qt.io
http://qt.io
Geschäftsführer: Mika Pälsi,
Juha Varelius, Mika Harjuaho
Sitz der Gesellschaft: Berlin, Registergericht: Amtsgericht Charlottenburg, HRB 144331 B
Dennis Luehring
2018-03-08 07:01:02 UTC
Permalink
Post by Eike Ziller
Check if the qmake step in your build configuration includes “-spec
win32-clang-msvc”.
Post by Eike Ziller
If not, then set “win32-clang-msvc” in the “Qt mkspec” >setting for
your kit and try again.
Post by Eike Ziller
I suppose Qt Creator might not do that automatically in your case.
is that "Qt mkspec" also working with Qbs?
Post by Eike Ziller
Qt 5.6 doesn’t have a mkspec for clang-cl, so you need to either create
one yourself, copy one from somewhere else (they are usually not
self-contained though), or use a Qt version which has one.
so i think it would be better using Qt5.8 for the first tests and try to
get back to 5.6 later

what about the C compiler detection problems?

(as i wrote) i've installed the current svn version of clang-cl from the
LLVM homepage
and my QtCreator 4.4.1 detected this C++ compiler:

LLVM 64bit based on MSVC2015 | Clang
Initalization: ...\vcvarsall.bat amd64
LLVM: C:\Program Files\LLVM

but no C compiler

should i upgrade to QtCreator 4.5 or later, or is the missing C compiler
handler by the “win32-clang-msvc” spec?
Markus Maier
2018-03-08 07:39:12 UTC
Permalink
Hi,

I can compile a project which also contains C files when setting "no
compiler" for the C compiler and selecting "LLVM ..." for C++.
The point here is that the win32-clang-msvc mkspec contains the following
line:
QMAKE_CXXFLAGS = $$QMAKE_CFLAGS
... which as far as I understand means that the C++ compiler is also used
for C files.

However there is the following bug in Qt Creator (which also describes how
to set up clang-cl quite well):
https://bugreports.qt.io/browse/QTCREATORBUG-19255
... which means that you'll have to re-configure the C++ compiler with
every restart of Qt Creator.

Best regards
Markus Maier
Check if the qmake step in your build configuration includes “-spec
win32-clang-msvc”.
If not, then set “win32-clang-msvc” in the “Qt mkspec” >setting for your
kit and try again.
I suppose Qt Creator might not do that automatically in your case.
is that "Qt mkspec" also working with Qbs?
Qt 5.6 doesn’t have a mkspec for clang-cl, so you need to either create
one yourself, copy one from somewhere else (they are usually not
self-contained though), or use a Qt version which has one.
so i think it would be better using Qt5.8 for the first tests and try to
get back to 5.6 later
what about the C compiler detection problems?
(as i wrote) i've installed the current svn version of clang-cl from the
LLVM homepage
LLVM 64bit based on MSVC2015 | Clang
Initalization: ...\vcvarsall.bat amd64
LLVM: C:\Program Files\LLVM
but no C compiler
should i upgrade to QtCreator 4.5 or later, or is the missing C compiler
handler by the “win32-clang-msvc” spec?
_______________________________________________
Qt-creator mailing list
http://lists.qt-project.org/mailman/listinfo/qt-creator
Markus Maier
2018-03-08 07:48:31 UTC
Permalink
Post by Markus Maier
Post by Markus Maier
QMAKE_CXXFLAGS = $$QMAKE_CFLAGS
Wrong line, sorry. I meant the following lines in qmake.conf of
win32-clang-msvc:
QMAKE_CC = clang-cl
QMAKE_CXX = $$QMAKE_CC
Post by Markus Maier
Hi,
I can compile a project which also contains C files when setting "no
compiler" for the C compiler and selecting "LLVM ..." for C++.
The point here is that the win32-clang-msvc mkspec contains the following
QMAKE_CXXFLAGS = $$QMAKE_CFLAGS
... which as far as I understand means that the C++ compiler is also used
for C files.
However there is the following bug in Qt Creator (which also describes how
https://bugreports.qt.io/browse/QTCREATORBUG-19255
... which means that you'll have to re-configure the C++ compiler with
every restart of Qt Creator.
Best regards
Markus Maier
Post by Markus Maier
Check if the qmake step in your build configuration includes “-spec
win32-clang-msvc”.
If not, then set “win32-clang-msvc” in the “Qt mkspec” >setting for
your kit and try again.
I suppose Qt Creator might not do that automatically in your case.
is that "Qt mkspec" also working with Qbs?
Qt 5.6 doesn’t have a mkspec for clang-cl, so you need to either create
one yourself, copy one from somewhere else (they are usually not
self-contained though), or use a Qt version which has one.
so i think it would be better using Qt5.8 for the first tests and try to
get back to 5.6 later
what about the C compiler detection problems?
(as i wrote) i've installed the current svn version of clang-cl from the
LLVM homepage
LLVM 64bit based on MSVC2015 | Clang
Initalization: ...\vcvarsall.bat amd64
LLVM: C:\Program Files\LLVM
but no C compiler
should i upgrade to QtCreator 4.5 or later, or is the missing C compiler
handler by the “win32-clang-msvc” spec?
_______________________________________________
Qt-creator mailing list
http://lists.qt-project.org/mailman/listinfo/qt-creator
Eike Ziller
2018-03-08 07:50:18 UTC
Permalink
Post by Dennis Luehring
Post by Eike Ziller
Check if the qmake step in your build configuration includes “-spec win32-clang-msvc”.
If not, then set “win32-clang-msvc” in the “Qt mkspec” >setting for your kit and try again.
I suppose Qt Creator might not do that automatically in your case.
is that "Qt mkspec" also working with Qbs?
Sorry, didn’t see that you use Qbs. No, qbs doesn’t use mkspecs. I do not know how Qbs knows what compiler exactly to call or how Qt Creator tells it which one it is.
Post by Dennis Luehring
Post by Eike Ziller
Qt 5.6 doesn’t have a mkspec for clang-cl, so you need to either create
one yourself, copy one from somewhere else (they are usually not
self-contained though), or use a Qt version which has one.
so i think it would be better using Qt5.8 for the first tests and try to get back to 5.6 later
what about the C compiler detection problems?
(as i wrote) i've installed the current svn version of clang-cl from the LLVM homepage
LLVM 64bit based on MSVC2015 | Clang
Initalization: ...\vcvarsall.bat amd64
LLVM: C:\Program Files\LLVM
but no C compiler
should i upgrade to QtCreator 4.5 or later, or is the missing C compiler
handler by the “win32-clang-msvc” spec?
--
Eike Ziller
Principal Software Engineer

The Qt Company GmbH
Rudower Chaussee 13
D-12489 Berlin
***@qt.io
http://qt.io
Geschäftsführer: Mika Pälsi,
Juha Varelius, Mika Harjuaho
Sitz der Gesellschaft: Berlin, Registergericht: Amtsgericht Charlottenburg, HRB 144331 B
Christian Kandeler
2018-03-08 08:29:06 UTC
Permalink
On Wed, 7 Mar 2018 20:17:08 +0100
Post by Dennis Luehring
my current setup is
QtCreator 4.4.1 (or 4.5 if needed), Qbs, Qt 5.6x and Visual Studio 2015
as my C/C++ x64 Compiler
my project can be compiled, linked, debugged - everything is working
an after reading the news about google using clang-cl for building
Chrome for the windows platform
http://blog.llvm.org/2018/03/clang-is-now-used-to-build-chrome-for.html
and want to give it a try - but how?
I don't think this works out of the box at the moment. You might want to
track https://bugreports.qt.io/browse/QBS-1316.


Christian

Loading...