Skip to content

Instantly share code, notes, and snippets.

@adanner
Last active April 22, 2022 16:07
Show Gist options
  • Select an option

  • Save adanner/161169596c9c9a57c751a7e5e0841210 to your computer and use it in GitHub Desktop.

Select an option

Save adanner/161169596c9c9a57c751a7e5e0841210 to your computer and use it in GitHub Desktop.
Fix QtCreator not finding CMake

Problem Description

QtCreator complains on opening new CMakeLists.txt project that

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.

The full error log starts

Running "/usr/bin/cmake /home/adas/cs40/examples '-GCodeBlocks - Unix Makefiles' -DCMAKE_CXX_COMPILER:STRING= -DQT_QMAKE_EXECUTABLE:STRING=/usr/lib/x86_64-linux-gnu/qt5/bin/qmake" in /tmp/qtc-cmake-YX2DyA.
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is unknown
...

Indeed the CMAKE_CXX_COMPILER string is empty

Possible Fix

  • Open qtcreator
  • On the top menu, go to Tools->Options
  • Select Build & Run icon on left side See the buildrun.png image above
  • Select Kits on top tab
  • Select Desktop (default)
  • Select a legit compiler from the compiler menu, e.g., Clang x86 64bit
    • If no options show up in the drop down, you may need to select manage and manually add /usr/bing/clang++ See compiler.png above
  • Select Apply
@dylanliuh2o
Copy link

It works! So what caused this problem?

@adanner
Copy link
Author

adanner commented Apr 22, 2022

Glad you found this five year old note helpful. I don't know the cause of the problem. That's perhaps a Qt question.

@dylanliuh2o
Copy link

Glad you found this five year old note helpful. I don't know the cause of the problem. That's perhaps a Qt question.

Ok, it's fine. This has helped me a lot. Thanks again! 😀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment