Tag Archives: CMake Error

[Solved] CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage

CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage

1. Error report Description:

Error reporting when building C + + program with cmake:

$ cmake .
-- Building for: NMake Makefiles
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


CMake Error at CMakeLists.txt:2 (project):
  Running

   'nmake' '-?'

  failed with:

   The system cannot find the specified file.


CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
See also "C:/Users/eren.luo/Desktop/test/CMakeFiles/CMakeOutput.log".

2. Solution:

P. S. mingw64/bin and cmake have been added to the environment variable.

Modify

cmake .

to:

cmake -G "MinGW Makefiles" .

Use the following commands to run:

mingw32-make.exe all

3. the version of C++ and cmake:

  1. cmake-3.23.1-windows-x86_64.msi
  2. mingw-w64-install.exe

System: Windows 10

[Solved] CMake Error: Error: generator : Unix Makefiles

The following problems occurred when using cmake – G “MinGW makefiles”

CMake Error: Error: generator : Unix Makefiles
Does not match the generator used previously: MinGW Makefiles
Either remove the CMakeCache.txt file and CMakeFiles directory or choose a different binary directory.

The reason is that it has been generated before, and other problems have not been deleted before regeneration
Solution:
1. Delete the previously generated files inside the build file
2. Create a new folder, cd to the new folder and re-cmake

[Solved] CMake Error: Could not create named generator Visual Studio 16 2019 -A Win64

Preface
CMake Error: Could not create named generator Visual Studio 16 2019 -A Win64
When using vcpkg to compile OsgEarth, the official compilation method is:
cmake -S osgearth -B build -G “Visual Studio 15 2017 Win64” -DCMAKE_BUILD_TYPE=RelWithDebInfo -DWIN32_USE_MP=ON -DCMAKE_INSTALL_PREFIX=[installroot] -DCMAKE_TOOLCHAIN_FILE=[vcpkgroot]\scripts\buildsystems\vcpkg.cmake


Change the commands below:
cmake -S osgearth -B build -G “Visual Studio 15 2017 Win64” -DCMAKE_BUILD_TYPE=RelWithDebInfo -DWIN32_USE_MP=ON -DCMAKE_INSTALL_PREFIX=[installroot] -DCMAKE_TOOLCHAIN_FILE=[vcpkgroot]\scripts\buildsystems\vcpkg.cmake
to:
cmake -S osgearth -B build -G “Visual Studio 16 2019” -DCMAKE_BUILD_TYPE=RelWithDebInfo -DWIN32_USE_MP=ON -DCMAKE_INSTALL_PREFIX=E:\osgEarth\vcpkg\vcpkg\build -DCMAKE_TOOLCHAIN_FILE=E:\osgEarth\vcpkg\vcpkg\scripts\buildsystems\vcpkg.cmake
That is
(1) Remove Win64
(2) Then change installroot to your OsgEarth generation project path, for example, here is: the path to generate OsgEarth.sln project

(3) Set the path of vcpkg.cmake to
Here:

CMake Error: The source directory “opencv Install Catalog“ does not appear to contain CMakeLists.txt.

Cmake error: the source directory “opencv installation directory” does not appear to contain cmakelists.txt

I want to build opencv 4.5.0 in Ubuntu 20.04 this morning; In the C + + environment, I tried to learn opencv in the Linux system, but I was not familiar with the use of Linux system. I was puzzled by one step in building the environment, and the error was as follows:

Cmake error: the source directory “opencv installation directory” does not appear to contain cmakelists.txt

In Baidu search, we found many solutions provided by big men. After some attempts, we failed collectively. After carefully studying the reasons for the error and checking our opencv installation directory, we found that the specific path of our cmakelists.txt is "home"/ ××××/ Opencv/opencv master/cmakelists.txt " instead of " home/ ×××/ Opencv/cmakelists. TXT ", finally found the cause of the error and solved the problem. Therefore, I hope this article can help some beginners like me. Thank you for your support!

Cmake Error The C compiler identification is GNU 7.5.0 — The CXX compiler identification is unknown

-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is unknown
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
CMake Error at CMakeLists.txt:2 (project):
  No CMAKE_CXX_COMPILER could be found.

  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 "/home/xxx/train_lianxi/build/CMakeFiles/CMakeOutput.log".
See also "/home/xxx/train_lianxi/build/CMakeFiles/CMakeError.log".

Install GCC, g++

sudo apt-get install gcc g++

CMake Error at CMakeLists.txt:5 (PROJECT): The CMAKE_C_COMPILER: cl is not a full path

Error info:
– Building for NMake Makefiles
— The C compiler identification is unknown
— The CXX compiler identification is unknown
CMake Error at CMakeLists. txt:5 (PROJECT):
The CMAKE_C_COMPILER:
cl
is not a full path and was not found in the PATH.
To use the NMake generator with Visual C++, c make must be run from a shell that can use the compiler cl from the command line.   This environment is unable to invoke the cl compiler.   To fix this problem, run CMake from the
Visual Studio Command Prompt (vcvarsall.bat).
Tell CMake where to find the compiler by setting either the environment
variable “CC” or the CMake cache entry CMAKE_C_COMPILER to the full path to
the compiler, or to the compiler name if it is in the PATH.

CMake Error at CMakeLists. txt:5 (PROJECT):
The CMAKE_CXX_COMPILER:
cl
is not a full path and was not found in the PATH.
To use the NMake generator with Visual C++, c make must be run from a shell that can use the compiler cl from the command line.   This environment is unable to invoke the cl compiler.   To fix this problem, run c make from the
Visual Studio Command Prompt (vcvarsall.bat).
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 “E:/gc/c_test1/build/CMakeFiles/CMakeOutput.log”.
See also “E:/gc/c_test1/build/CMakeFiles/CMakeError.log”.

How to Fix
1.Don’t use make.. Use  these  commands:

cmake -G "MSYS Makefiles" ..

2. If the first one doesn’t work, set the path:

$ export CC=/c/MinGW/bin/gcc.exe
$ export CXX=/c/MinGW/bin/g++.exe
$ cmake -G "MinGW Makefiles" ..
-- The CXX compiler identification is GNU 4.8.1        
...
$ mingw32-make

The second:

$ cmake -DCMAKE_C_COMPILER=/c/MinGW/bin/gcc.exe -DCMAKE_CXX_COMPILER=/c/MinGW/bin/g++.exe ..

If not, please refer to the following link:
https://www.e-learn.cn/content/wangluowenzhang/22835
https://stackoverflow.com/questions/29746950/cmake-cannot-find-compiler