# CMake fails to build simplest possible example

**URL:** https://discourse.cmake.org/t/cmake-fails-to-build-simplest-possible-example/4702
**Category:** Code
**Tags:** os:linux
**Created:** [December 18, 2021, 12:14am UTC](https://discourse.cmake.org/t/cmake-fails-to-build-simplest-possible-example/4702 "2021-12-18T00:14:53Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![jspaceboots](https://discourse.cmake.org/user_avatar/discourse.cmake.org/jspaceboots/32/2043_2.png) [@jspaceboots](https://discourse.cmake.org/u/jspaceboots)
#### Post date: [December 18, 2021, 12:14am UTC](https://discourse.cmake.org/t/cmake-fails-to-build-simplest-possible-example/4702/1 "2021-12-18T00:14:53Z")

</div>

Apologies in advance for how simple this is, very new to CMake and can’t get the simplest possible example working.

I’ve got a project consisting of a single .c file (main.c), the contents of which are:

```auto
#include <stdio.h>

int main() {
    return 0;
}

```

In the same directory I’ve got a CMakeLists.txt file:

```auto
cmake_minimum_required(VERSION 3.10)
project(Test VERSION 1.0
                    DESCRIPTION "CMake Test"
                    LANGUAGES c)
add_executable(Test main.c)

```

Running `cmake ./` in this directory results in:

```auto
CMake Error: Could not find cmake module file: CMakeDeterminecCompiler.cmake
CMake Error: Error required internal CMake variable not set, cmake may not be built correctly.
Missing variable is:
CMAKE_c_COMPILER_ENV_VAR
CMake Error: Error required internal CMake variable not set, cmake may not be built correctly.
Missing variable is:
CMAKE_c_COMPILER
CMake Error: Could not find cmake module file: /home/j/projects/poc/cmaketut/CMakeFiles/3.20.5/CMakecCompiler.cmake
CMake Error at CMakeLists.txt:2 (project):
  No CMAKE_c_COMPILER could be found.

  Tell CMake where to find the compiler by setting 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: Could not find cmake module file: CMakecInformation.cmake
CMake Error: CMAKE_c_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!

```

Looking in CMakeCache.txt I see: `CMAKE_C_COMPILER:FILEPATH=/usr/bin/cc`

and an ls -la /usr/bin/cc reveals that it is there:

```auto
lrwxrwxrwx 1 root root 43 Dec 12 13:47 /usr/bin/cc -> /usr/x86_64-pc-linux-gnu/gcc-bin/11.2.0/gcc

```

At this point I’m not really sure what I’ve done wrong.

---

<div class="post-metadata">

### Author: ![vre](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/v/f04885/32.png) [@vre](https://discourse.cmake.org/u/vre)
#### Post date: [December 18, 2021, 12:28am UTC](https://discourse.cmake.org/t/cmake-fails-to-build-simplest-possible-example/4702/2 "2021-12-18T00:28:50Z")

</div>

Your `LANGUAGES` setting is wrong. It is called `C` (with an uppercase C). But you don’t need to give the project command a `LANGUAGES` argument at all, as `C` and `CXX` are defaults.

---

<div class="post-metadata">

### Author: ![jspaceboots](https://discourse.cmake.org/user_avatar/discourse.cmake.org/jspaceboots/32/2043_2.png) [@jspaceboots](https://discourse.cmake.org/u/jspaceboots)
#### Post date: [December 18, 2021, 12:31am UTC](https://discourse.cmake.org/t/cmake-fails-to-build-simplest-possible-example/4702/3 "2021-12-18T00:31:36Z")

</div>

I knew it’d be something silly on my end, thanks, that got it working.
