QtCreator does not pick up compiler configured in Kit
-
I'm seeing this while cross-building to RPi. I find that the only way to use a specific compiler is to specify the path via
QMAKE_CC
andQMAKE_CXX
in the.pro
file. Selecting the desired compiler as part of the Kit doesn't work. If I only select the compiler in the Kit, the build somehow defaults to using the compiler used for cross-compiling Qt itself.Why does this happen, and how can I enforce use of a specific compiler without hardcoding it in the
.pro
file? -
@vikramg You need to setup your cross-environment properly. Most often, the cross-compilers have an
environment-setup
shell script or similar. This sets the environment variables needed for cross-compiling.You can either source this script in a shell before starting Qt Creator, or put the (expanded) variables in Qt Creators Kit settings (which I prefer). Then it is easily possible to switch between Desktop and embedded target.
Regards
-
@aha_1980 Can you elaborate on this env-setup script? What does it contain? I am using the cross compiler from Linaro here: https://releases.linaro.org/components/toolchain/binaries/latest-7/armv8l-linux-gnueabihf. That tarball just has the x86-64 cross-executables, and ARM libraries and headers. No env setup script of any sort. Is there documentation for what env variables are read by QtCreator for cross compilation?
I am able to switch kits right now and build at will for Desktop and embedded; the only hiccup is that QtCreator seemingly does not pick the compiler from the kit for the embedded target, so I have to hardcode it in the
.pro
file. -
@vikramg I don't have access to my machine right now, but if you say it works with the variables you changed in the pro file, I'd say setting the
CC
andCXX
env variables could already work.I'm using the Yocto SDK, and there much more env variables are set in the script.
Regards
-
@aha_1980 Hmm, but that is no more advantageous than having the variables in the pro file. It is still baffling as to why QtCreator would ignore the compiler set in the Kit. Ideally I would like to have multiple cross-compilers configured, and be able to switch between them by selecting the desired one in the Compiler dropdown in the Kit configuration.
-
Hmm, but that is no more advantageous than having the variables in the pro file.
It is, because you can change the kit for a project easily. if you hardcode in project, you can't.
Cross-compiling has always been done by setting
CC
to the correct compiler. Creator does not build your project,make
does. That's the reason thrse old habits still apply. And as I said, most often more variables need to be set.
Regards -
Cross-compiling has always been done by setting CC to the correct compiler. Creator does not build your project, make does. That's the reason thrse old habits still apply.
Ah, I see. I still think QtCreator could set up the compiler-related env vars for you before launching the build, but I'll keep using the
CC
/CXX
then.