- Qt Creator can’t find CMAKE_CXX_COMPILER compiler in linux mint 64 bit
- 2 Answers 2
- cmake-toolchains(7)В¶
- Introduction¶
- Languages¶
- Variables and Properties¶
- Toolchain Features¶
- Cross Compiling¶
- Cross Compiling for Linux¶
- Cross Compiling for the Cray Linux Environment¶
- Cross Compiling using Clang¶
- Cross Compiling for QNX¶
- Cross Compiling for Windows CE¶
- Cross Compiling for Windows 10 Universal Applications¶
- Cross Compiling for Windows Phone¶
- Cross Compiling for Windows Store¶
- Cross Compiling for Android¶
- Cross Compiling for Android with the NDK¶
- Cross Compiling for Android with a Standalone Toolchain¶
- Cross Compiling for Android with NVIDIA Nsight Tegra Visual Studio Edition¶
Qt Creator can’t find CMAKE_CXX_COMPILER compiler in linux mint 64 bit
I’m trying to use cmake to build a simple hello world c++ application in Qt Creator 4.7.0-beta1 and I get the following error:
Tell CMake where to find the compiler by setting either the environment variable «CXX» or the CMake cache entry CMAKE_CXX_COMPILER to the full path to the compiler, or to the compiler name if it is in the PATH.
— Configuring incomplete, errors occurred! See also «/tmp/QtCreator-CRirhE/qtc-cmake-DuSxtHku/CMakeFiles/CMakeOutput.log». See also «/tmp/QtCreator-CRirhE/qtc-cmake-DuSxtHku/CMakeFiles/CMakeError.log». *** cmake process exited with exit code 1.
I have build-essentials installed, and I have also set the cxx path to g++. I have also uninstalled and reinstalled g++ and gcc.
2 Answers 2
It happens as your qtproject kits can’t find the suitable compiler for cmake.
For CMAKE convenience first install Ninja-Build. Also you will need GCC or Clang and GDB.
And for qt environment setup convenience you can use:
apt install qt5-default or apt install qt4-default
Now ninja will try to configure your cmake properly.
You may also need to go to:
. then select the kit you need to use and in compiler section select gcc or clang c++ for c++ compiler and gcc or clang c for c compiler.
This error appears when the compiler is not correctly set, and thus, cmake is not able to find it.
This is obvious, but when you are using QtCreator, you have to take into account where this information is defined. It is defined in the «kit» specification.
First of all, check if your «Kit» is properly configured. Go to the menus and select:
Then, in the Options window, select «Build & Run» in the left column. Then, select the «Kits» tab in the right panel. There you can see a list of the available Kits.
Select the kit you want to use. If you have more than one option and you don’t know which one choose to use the default option (i.e. «Desktop Qt 5.2.1 GCC 64bit (default)»).
In the kit configuration list, check the row named «Compiler». If the C++ compiler is configured as «No compiler, there is the problem. Select one of the compilers in the list (you can select the base GCC (C++) for example). Then press the «OK» button, and try to generate the project from scratch (remove the generated files and open it again).
If the compiler is configured, make sure that is the correct one, and check if the path to the binary is correct.
NOTE: If the list has not the desired compiler, you can add it in the «Compilers» tab. There, press «Add» button and select the desired options.
NOTE2: If the compiler list is empty. maybe you need to install QtCreator again.
Источник
cmake-toolchains(7)В¶
Introduction¶
CMake uses a toolchain of utilities to compile, link libraries and create archives, and other tasks to drive the build. The toolchain utilities available are determined by the languages enabled. In normal builds, CMake automatically determines the toolchain for host builds based on system introspection and defaults. In cross-compiling scenarios, a toolchain file may be specified with information about compiler and utility paths.
Languages¶
Languages are enabled by the project() command. Language-specific built-in variables, such as _COMPILER»> _COMPILER» title=»CMAKE_ _COMPILER»> CMAKE_CXX_COMPILER , _COMPILER_ID»> _COMPILER_ID» title=»CMAKE_ _COMPILER_ID»> CMAKE_CXX_COMPILER_ID etc are set by invoking the project() command. If no project command is in the top-level CMakeLists file, one will be implicitly generated. By default the enabled languages are C and CXX :
A special value of NONE can also be used with the project() command to enable no languages:
The enable_language() command can be used to enable languages after the project() command:
When a language is enabled, CMake finds a compiler for that language, and determines some information, such as the vendor and version of the compiler, the target architecture and bitwidth, the location of corresponding utilities etc.
The ENABLED_LANGUAGES global property contains the languages which are currently enabled.
Variables and Properties¶
Several variables relate to the language components of a toolchain which are enabled. _COMPILER»> _COMPILER» title=»CMAKE_ _COMPILER»> CMAKE_ _COMPILER is the full path to the compiler used for . _COMPILER_ID»> _COMPILER_ID» title=»CMAKE_ _COMPILER_ID»> CMAKE_ _COMPILER_ID is the identifier used by CMake for the compiler and _COMPILER_VERSION»> _COMPILER_VERSION» title=»CMAKE_ _COMPILER_VERSION»> CMAKE_ _COMPILER_VERSION is the version of the compiler.
The _FLAGS»> _FLAGS» title=»CMAKE_ _FLAGS»> CMAKE_ _FLAGS variables and the configuration-specific equivalents contain flags that will be added to the compile command when compiling a file of a particular language.
As the linker is invoked by the compiler driver, CMake needs a way to determine which compiler to use to invoke the linker. This is calculated by the LANGUAGE of source files in the target, and in the case of static libraries, the language of the dependent libraries. The choice CMake makes may be overridden with the LINKER_LANGUAGE target property.
Toolchain Features¶
CMake provides the try_compile() command and wrapper macros such as CheckCXXSourceCompiles , CheckCXXSymbolExists and CheckIncludeFile to test capability and availability of various toolchain features. These APIs test the toolchain in some way and cache the result so that the test does not have to be performed again the next time CMake runs.
Some toolchain features have built-in handling in CMake, and do not require compile-tests. For example, POSITION_INDEPENDENT_CODE allows specifying that a target should be built as position-independent code, if the compiler supports that feature. The _VISIBILITY_PRESET»> _VISIBILITY_PRESET» title=» _VISIBILITY_PRESET»> _VISIBILITY_PRESET and VISIBILITY_INLINES_HIDDEN target properties add flags for hidden visibility, if supported by the compiler.
Cross Compiling¶
If cmake(1) is invoked with the command line parameter —toolchain path/to/file or -DCMAKE_TOOLCHAIN_FILE=path/to/file , the file will be loaded early to set values for the compilers. The CMAKE_CROSSCOMPILING variable is set to true when CMake is cross-compiling.
Note that using the CMAKE_SOURCE_DIR or CMAKE_BINARY_DIR variables inside a toolchain file is typically undesirable. The toolchain file is used in contexts where these variables have different values when used in different places (e.g. as part of a call to try_compile() ). In most cases, where there is a need to evaluate paths inside a toolchain file, the more appropriate variable to use would be CMAKE_CURRENT_LIST_DIR , since it always has an unambiguous, predictable value.
Cross Compiling for Linux¶
A typical cross-compiling toolchain for Linux has content such as:
The CMAKE_SYSTEM_NAME is the CMake-identifier of the target platform to build for.
The CMAKE_SYSTEM_PROCESSOR is the CMake-identifier of the target architecture to build for.
The CMAKE_SYSROOT is optional, and may be specified if a sysroot is available.
The CMAKE_STAGING_PREFIX is also optional. It may be used to specify a path on the host to install to. The CMAKE_INSTALL_PREFIX is always the runtime installation location, even when cross-compiling.
The _COMPILER»> _COMPILER» title=»CMAKE_ _COMPILER»> CMAKE_ _COMPILER variables may be set to full paths, or to names of compilers to search for in standard locations. For toolchains that do not support linking binaries without custom flags or scripts one may set the CMAKE_TRY_COMPILE_TARGET_TYPE variable to STATIC_LIBRARY to tell CMake not to try to link executables during its checks.
CMake find_* commands will look in the sysroot, and the CMAKE_FIND_ROOT_PATH entries by default in all cases, as well as looking in the host system root prefix. Although this can be controlled on a case-by-case basis, when cross-compiling, it can be useful to exclude looking in either the host or the target for particular artifacts. Generally, includes, libraries and packages should be found in the target system prefixes, whereas executables which must be run as part of the build should be found only on the host and not on the target. This is the purpose of the CMAKE_FIND_ROOT_PATH_MODE_* variables.
Cross Compiling for the Cray Linux Environment¶
Cross compiling for compute nodes in the Cray Linux Environment can be done without needing a separate toolchain file. Specifying -DCMAKE_SYSTEM_NAME=CrayLinuxEnvironment on the CMake command line will ensure that the appropriate build settings and search paths are configured. The platform will pull its configuration from the current environment variables and will configure a project to use the compiler wrappers from the Cray Programming Environment’s PrgEnv-* modules if present and loaded.
The default configuration of the Cray Programming Environment is to only support static libraries. This can be overridden and shared libraries enabled by setting the CRAYPE_LINK_TYPE environment variable to dynamic .
Running CMake without specifying CMAKE_SYSTEM_NAME will run the configure step in host mode assuming a standard Linux environment. If not overridden, the PrgEnv-* compiler wrappers will end up getting used, which if targeting the either the login node or compute node, is likely not the desired behavior. The exception to this would be if you are building directly on a NID instead of cross-compiling from a login node. If trying to build software for a login node, you will need to either first unload the currently loaded PrgEnv-* module or explicitly tell CMake to use the system compilers in /usr/bin instead of the Cray wrappers. If instead targeting a compute node is desired, just specify the CMAKE_SYSTEM_NAME as mentioned above.
Cross Compiling using Clang¶
Some compilers such as Clang are inherently cross compilers. The _COMPILER_TARGET»> _COMPILER_TARGET» title=»CMAKE_ _COMPILER_TARGET»> CMAKE_ _COMPILER_TARGET can be set to pass a value to those supported compilers when compiling:
Similarly, some compilers do not ship their own supplementary utilities such as linkers, but provide a way to specify the location of the external toolchain which will be used by the compiler driver. The _COMPILER_EXTERNAL_TOOLCHAIN»> _COMPILER_EXTERNAL_TOOLCHAIN» title=»CMAKE_ _COMPILER_EXTERNAL_TOOLCHAIN»> CMAKE_ _COMPILER_EXTERNAL_TOOLCHAIN variable can be set in a toolchain file to pass the path to the compiler driver.
Cross Compiling for QNX¶
As the Clang compiler the QNX QCC compile is inherently a cross compiler. And the _COMPILER_TARGET»> _COMPILER_TARGET» title=»CMAKE_ _COMPILER_TARGET»> CMAKE_ _COMPILER_TARGET can be set to pass a value to those supported compilers when compiling:
Cross Compiling for Windows CE¶
Cross compiling for Windows CE requires the corresponding SDK being installed on your system. These SDKs are usually installed under C:/Program Files (x86)/Windows CE Tools/SDKs .
A toolchain file to configure a Visual Studio generator for Windows CE may look like this:
The CMAKE_GENERATOR_PLATFORM tells the generator which SDK to use. Further CMAKE_SYSTEM_VERSION tells the generator what version of Windows CE to use. Currently version 8.0 (Windows Embedded Compact 2013) is supported out of the box. Other versions may require one to set CMAKE_GENERATOR_TOOLSET to the correct value.
Cross Compiling for Windows 10 Universal Applications¶
A toolchain file to configure a Visual Studio generator for a Windows 10 Universal Application may look like this:
A Windows 10 Universal Application targets both Windows Store and Windows Phone. Specify the CMAKE_SYSTEM_VERSION variable to be 10.0 to build with the latest available Windows 10 SDK. Specify a more specific version (e.g. 10.0.10240.0 for RTM) to build with the corresponding SDK.
Cross Compiling for Windows Phone¶
A toolchain file to configure a Visual Studio generator for Windows Phone may look like this:
Cross Compiling for Windows Store¶
A toolchain file to configure a Visual Studio generator for Windows Store may look like this:
Cross Compiling for Android¶
A toolchain file may configure cross-compiling for Android by setting the CMAKE_SYSTEM_NAME variable to Android . Further configuration is specific to the Android development environment to be used.
For Visual Studio Generators , CMake expects NVIDIA Nsight Tegra Visual Studio Edition or the Visual Studio tools for Android to be installed. See those sections for further configuration details.
For Makefile Generators and the Ninja generator, CMake expects one of these environments:
CMake uses the following steps to select one of the environments:
If the CMAKE_ANDROID_NDK variable is set, the NDK at the specified location will be used.
Else, if the CMAKE_ANDROID_STANDALONE_TOOLCHAIN variable is set, the Standalone Toolchain at the specified location will be used.
Else, if the CMAKE_SYSROOT variable is set to a directory of the form /platforms/android-/arch- , the part will be used as the value of CMAKE_ANDROID_NDK and the NDK will be used.
Else, if the CMAKE_SYSROOT variable is set to a directory of the form /sysroot , the part will be used as the value of CMAKE_ANDROID_STANDALONE_TOOLCHAIN and the Standalone Toolchain will be used.
Else, if a cmake variable ANDROID_NDK is set it will be used as the value of CMAKE_ANDROID_NDK , and the NDK will be used.
Else, if a cmake variable ANDROID_STANDALONE_TOOLCHAIN is set, it will be used as the value of CMAKE_ANDROID_STANDALONE_TOOLCHAIN , and the Standalone Toolchain will be used.
Else, if an environment variable ANDROID_NDK_ROOT or ANDROID_NDK is set, it will be used as the value of CMAKE_ANDROID_NDK , and the NDK will be used.
Else, if an environment variable ANDROID_STANDALONE_TOOLCHAIN is set then it will be used as the value of CMAKE_ANDROID_STANDALONE_TOOLCHAIN , and the Standalone Toolchain will be used.
Else, an error diagnostic will be issued that neither the NDK or Standalone Toolchain can be found.
New in version 3.20: If an Android NDK is selected, its version number is reported in the CMAKE_ANDROID_NDK_VERSION variable.
Cross Compiling for Android with the NDK¶
A toolchain file may configure Makefile Generators , Ninja Generators , or Visual Studio Generators to target Android for cross-compiling.
Configure use of an Android NDK with the following variables:
Set to Android . Must be specified to enable cross compiling for Android.
Set to the Android API level. If not specified, the value is determined as follows:
If the CMAKE_ANDROID_API variable is set, its value is used as the API level.
If the CMAKE_SYSROOT variable is set, the API level is detected from the NDK directory structure containing the sysroot.
Otherwise, the latest API level available in the NDK is used.
Set to the Android ABI (architecture). If not specified, this variable will default to the first supported ABI in the list of armeabi , armeabi-v7a and arm64-v8a . The CMAKE_ANDROID_ARCH variable will be computed from CMAKE_ANDROID_ARCH_ABI automatically. Also see the CMAKE_ANDROID_ARM_MODE and CMAKE_ANDROID_ARM_NEON variables.
Set to the absolute path to the Android NDK root directory. If not specified, a default for this variable will be chosen as specified above .
Set to a true value to use the deprecated per-api-level headers instead of the unified headers. If not specified, the default will be false unless using a NDK that does not provide unified headers.
On NDK r19 or above, this variable must be unset or set to clang . On NDK r18 or below, set this to the version of the NDK toolchain to be selected as the compiler. If not specified, the default will be the latest available GCC toolchain.
Set to specify which C++ standard library to use. If not specified, a default will be selected as described in the variable documentation.
The following variables will be computed and provided automatically:
The absolute path prefix to the binutils in the NDK toolchain.
The host platform suffix of the binutils in the NDK toolchain.
For example, a toolchain file might contain:
Alternatively one may specify the values without a toolchain file:
Cross Compiling for Android with a Standalone Toolchain¶
A toolchain file may configure Makefile Generators or the Ninja generator to target Android for cross-compiling using a standalone toolchain.
Configure use of an Android standalone toolchain with the following variables:
Set to Android . Must be specified to enable cross compiling for Android.
Set to the absolute path to the standalone toolchain root directory. A $
When the standalone toolchain targets ARM, optionally set this to ON to target 32-bit ARM instead of 16-bit Thumb. See variable documentation for details.
When the standalone toolchain targets ARM v7, optionally set thisto ON to target ARM NEON devices. See variable documentation for details.
The following variables will be computed and provided automatically:
The Android API level detected from the standalone toolchain.
The Android ABI detected from the standalone toolchain.
The absolute path prefix to the binutils in the standalone toolchain.
The host platform suffix of the binutils in the standalone toolchain.
For example, a toolchain file might contain:
Alternatively one may specify the values without a toolchain file:
Cross Compiling for Android with NVIDIA Nsight Tegra Visual Studio Edition¶
A toolchain file to configure one of the Visual Studio Generators to build using NVIDIA Nsight Tegra targeting Android may look like this:
The CMAKE_GENERATOR_TOOLSET may be set to select the Nsight Tegra «Toolchain Version» value.
Источник