Cmake Error

I am using Windows Subsystem for Linux (WSL), to run a project. I am encountering some errors when I try to build my project.
[cmake] Not searching for unused variables given on the command line.
[cmake] – The C compiler identification is GNU 7.2.0
[cmake] – The CXX compiler identification is GNU 7.2.0
[cmake] – Check for working C compiler: /mnt/c/Program Files/Haskell Platform/8.6.3/mingw/bin/gcc.exe
[cmake] – Check for working C compiler: /mnt/c/Program Files/Haskell Platform/8.6.3/mingw/bin/gcc.exe – broken
[cmake] CMake Error at /usr/share/cmake-3.16/Modules/CMakeTestCCompiler.cmake:60 (message):
[cmake] The C compiler
[cmake] “/mnt/c/Program Files/Haskell Platform/8.6.3/mingw/bin/gcc.exe”
[cmake] is not able to compile a simple test program.
[cmake] It fails with the following output:
[cmake] Change Dir: /mnt/c/Users/uosuj/source/repos/MyProject/oop/build/CMakeFiles/CMakeTmp
[cmake] Run Build Command(s):/usr/bin/make cmTC_bd248/fast && make: Warning: File ‘Makefile’ has modification time 16 s in the future
[cmake] /usr/bin/make -f CMakeFiles/cmTC_bd248.dir/build.make CMakeFiles/cmTC_bd248.dir/build
[cmake] make[1]: Entering directory ‘/mnt/c/Users/uosuj/source/repos/MyProject/oop/build/CMakeFiles/CMakeTmp’
[cmake] make[1]: Warning: File ‘CMakeFiles/cmTC_bd248.dir/flags.make’ has modification time 16 s in the future
[cmake] Building C object CMakeFiles/cmTC_bd248.dir/testCCompiler.c.o
[cmake] “/mnt/c/Program Files/Haskell Platform/8.6.3/mingw/bin/gcc.exe” -o CMakeFiles/cmTC_bd248.dir/testCCompiler.c.o -c /mnt/c/Users/uosuj/source/repos/MyProject/oop/build/CMakeFiles/CMakeTmp/testCCompiler.c
[cmake] realgcc.exe: error: /mnt/c/Users/uosuj/source/repos/MyProject/oop/build/CMakeFiles/CMakeTmp/testCCompiler.c: No such file or directory
[cmake] realgcc.exe: fatal error: no input files
[cmake] compilation terminated.
[cmake] make[1]: *** [CMakeFiles/cmTC_bd248.dir/build.make:66: CMakeFiles/cmTC_bd248.dir/testCCompiler.c.o] Error 1
[cmake] make[1]: Leaving directory ‘/mnt/c/Users/uosuj/source/repos/MyProject/oop/build/CMakeFiles/CMakeTmp’
[cmake] make: *** [Makefile:121: cmTC_bd248/fast] Error 2
[cmake] CMake will not be able to correctly generate this project.
[cmake] Call Stack (most recent call first):
[cmake] CMakeLists.txt:2 (project)
[cmake] – Configuring incomplete, errors occurred!
[cmake] See also “/mnt/c/Users/uosuj/source/repos/MyProject/oop/build/CMakeFiles/CMakeOutput.log”.
[cmake] See also “/mnt/c/Users/uosuj/source/repos/MyProject/oop/build/CMakeFiles/CMakeError.log”.
Please can someone help me figure this out as the deadline is fast approaching for the project.

It looks like you’re trying to build within WSL using a Windows compiler? That’s unlikely to work well. You should be able to get a compiler from the distro you’re using inside of WSL instead.

Thank you for your response. How can I get a compiler inside of WSL? Because from what I know, I already have gcc installed in WSL.

The GCC that is being found is coming from your Haskell SDK installation in your Windows machine. This is almost certainly a Windows compiler, not a Linux compiler. You’ll need to figure out what distribution is being used (cat /etc/os-release should help there) and follow the instructions for that distro to install them. If I had to guess, apt-get install build-essential is what you want).

Hi Ben,
I have the build essentials already installed. I read on stack overflow that it might be a cross compiling situation. But I still cannot figure it out.

Anyone has an idea how to resolve the issue above?

Maybe you should try to prevent Windows PATH from being added to WSL environment (like this) if the problem is the gcc outside in Windows shadows the gcc inside WSL.