Execution of mingw32.exe failed in codeblocks - codeblocks

I have installed CodeBlocks.
Now I am trying to execute my 1st C program. But it gives me the above mentioned error.
I have checked Settings->Compiler. The GNU GCC Comppiler is selected. Also in the Toolchains executables tab, the mingw32 folder is selected.

Related

MinGW C compiler "not able to compile a simple test program"

I want to run MinGW as a C compiler. MinGW has been installed from Chocolatey. Invocation is from gitlab-runner through CMake. This fails with
$ cmake -G "MinGW Makefiles" -DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc -DLIB_MAN=OFF -DCMAKE_INSTALL_PREFIX=C:\opt\x64 -B. ..
-- The C compiler identification is unknown
-- Check for working C compiler: C:/ProgramData/chocolatey/bin/x86_64-w64-mingw32-gcc.exe
-- Check for working C compiler: C:/ProgramData/chocolatey/bin/x86_64-w64-mingw32-gcc.exe -- broken
CMake Error at C:/Program Files/CMake/share/cmake-3.16/Modules/CMakeTestCCompiler.cmake:60 (message):
The C compiler
"C:/ProgramData/chocolatey/bin/x86_64-w64-mingw32-gcc.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/gitlab-runner/builds/zjE1Mkfg/0/mlz/kww/build/CMakeFiles/CMakeTmp
Run Build Command(s):C:/ProgramData/chocolatey/bin/mingw32-make.exe cmTC_ffa53/fast && C:/ProgramData/chocolatey/lib/mingw/tools/install/mingw64/bin/mingw32-make -f CMakeFiles\cmTC_ffa53.dir\build.make CMakeFiles/cmTC_ffa53.dir/build
mingw32-make[1]: Entering directory 'C:/gitlab-runner/builds/zjE1Mkfg/0/mlz/kww/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_ffa53.dir/testCCompiler.c.obj
C:\ProgramData\chocolatey\bin\x86_64-w64-mingw32-gcc.exe -o CMakeFiles\cmTC_ffa53.dir\testCCompiler.c.obj -c C:\gitlab-runner\builds\zjE1Mkfg\0\mlz\kww\build\CMakeFiles\CMakeTmp\testCCompiler.c
mingw32-make[1]: *** [CMakeFiles\cmTC_ffa53.dir\build.make:65: CMakeFiles/cmTC_ffa53.dir/testCCompiler.c.obj] Error 1
mingw32-make[1]: Leaving directory 'C:/gitlab-runner/builds/zjE1Mkfg/0/mlz/kww/build/CMakeFiles/CMakeTmp'
mingw32-make: *** [Makefile:120: cmTC_ffa53/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:6 (project)
-- Configuring incomplete, errors occurred!
See also "C:/gitlab-runner/builds/zjE1Mkfg/0/mlz/kww/build/CMakeFiles/CMakeOutput.log".
See also "C:/gitlab-runner/builds/zjE1Mkfg/0/mlz/kww/build/CMakeFiles/CMakeError.log".
ERROR: Job failed: exit status 1
From various web sources I understand that MinGW is bound to fail if sh.exe is present on the system [1]. However, sh.exe comes with several applications, among them Git and Visual Studio, which I cannot remove. Somewhere it's suggested to add -DCMAKE_SH="CMAKE_SH-NOTFOUND", which, however, has no effect.
I've seen a related question from 2015 [2], which however involves CLion. The only upvoted answer contains several broken links - altogether, that thread isn't helpful.
How to proceed? Is there a chance to work around the sh.exe problem?
Other advice on the web suggests to use -G "MSYS Makefiles". However, the CMake documentation [3] seems to rule this out: "not compatible with a Windows command prompt. To build under a Windows command prompt, use the MinGW Makefiles generator."
[1] https://stackoverflow.com/a/7411982/1017348
[2] CLion: Error:The C compiler "C:/MinGW/bin/gcc.exe" is not able to compile a simple test program
[3] https://cmake.org/cmake/help/latest/generator/MSYS%20Makefiles.html#generator:MSYS%20Makefiles per CMake 3.16.1
After long experimentation, I conclude that the problem comes from Chocolatey's packaging of MinGW. The problem is gone after I
uninstalled the MinGW package from Chocolatey,
reinstalled MinGW using the original MinGW installer,
installed the Ninja Chocolatey package,
inserted C:\MinGW\bin on top of PATH.
$ cmake -G "Ninja" -DLIB_MAN=OFF -DCMAKE_INSTALL_PREFIX=C:\opt\x64 -B. ..
-- The C compiler identification is GNU 8.2.0
-- Check for working C compiler: C:/MinGW/bin/gcc.exe
-- Check for working C compiler: C:/MinGW/bin/gcc.exe -- works
Also note:
There is no need for -DCMAKE_C_COMPILER=...
I did not try hard to get -G "MinGW Makefile" working; -G Ninja works just fine.
The sh.exe is only a problem when you run CMake the first time when trying to generate the project. You can rerun CMake again and CMake will continue with normal processing to generate the project (tested in version 3.16). I saw a patch that removes this check and should be part of a future release of CMake.
It's already mentioned that gcc is installed incorrectly. That always seems to be the case when anyone mentions that gcc fails with an Error 1 message. It should be noted that Error 1 is not from CMake. CMake is just gathering the output from when it runs mingw32-make to build the sample project.
The first message in the output -- The C compiler identification is unknown is a pretty clear message that your compiler isn't working. All of the output for this step is in the log and error files that CMake generates in the build folder. You'll be able to see how it invoked the compiler and with which options and the output from the compiler.

CLion + MinGW Test CMake run finished with errors

I'm new on this IDE, and programming on Windows, I've installed MinGW and added to enviroment path all is ok, I can compile and execute code from "cmd", but when I run CLion I have this error:
-- The C compiler identification is GNU 6.3.0
-- The CXX compiler identification is GNU 6.3.0
-- Check for working C compiler: C:/MinGW/bin/gcc.exe
-- Check for working C compiler: C:/MinGW/bin/gcc.exe -- broken
CMake Error at C:/Program Files/JetBrains/CLion 2017.3.1/bin/cmake/share/cmake-3.9/Modules/CMakeTestCCompiler.cmake:51 (message):
The C compiler "C:/MinGW/bin/gcc.exe" is not able to compile a simple test
program.
It fails with the following output:
Change Dir: C:/Users/noName/AppData/Local/Temp/cmake_check_environment/_build/CMakeFiles/CMakeTmp
Run Build Command:"C:/MinGW/bin/mingw32-make.exe" "cmTC_2e43b/fast"
C:/MinGW/bin/mingw32-make.exe -f CMakeFiles\cmTC_2e43b.dir\build.make
CMakeFiles/cmTC_2e43b.dir/build
mingw32-make.exe1: Entering directory
'C:/Users/noName/AppData/Local/Temp/cmake_check_environment/_build/CMakeFiles/CMakeTmp'
CMakeFiles\cmTC_2e43b.dir\build.make:64: recipe for target
'CMakeFiles/cmTC_2e43b.dir/testCCompiler.c.obj' failed
process_begin:
CreateProcess(C:\Users\noName\AppData\Local\Temp\make2428-1.bat,
C:\Users\noName\AppData\Local\Temp\make2428-1.bat, ...) failed.
make (e=2): El sistema no puede encontrar el archivo especificado.
mingw32-make.exe1: *** [CMakeFiles/cmTC_2e43b.dir/testCCompiler.c.obj]
Error 2
mingw32-make.exe1: Leaving directory
'C:/Users/noName/AppData/Local/Temp/cmake_check_environment/_build/CMakeFiles/CMakeTmp'
Makefile:125: recipe for target 'cmTC_2e43b/fast' failed
mingw32-make.exe: *** [cmTC_2e43b/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:1 (project)
-- Configuring incomplete, errors occurred!
See also "C:/Users/noName/AppData/Local/Temp/cmake_check_environment/_build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/noName/AppData/Local/Temp/cmake_check_environment/_build/CMakeFiles/CMakeError.log".
Error code: 1
This is the photo. I think this is and error with CMake(?)
your windows 64bit and you can't write gcc.exe and g++.exe in windows 64 . you should try installing mingw-w64.
you can download this From here and installing this.
after that you should go in CLion setting -> build,Execution,deployment -> Toolchains
and configuration like this picture
and for installer mingw-w64 you should installer default option.
I encountered the same problem with mingw-32. Here is my solution.
First I removed all packages through MinGW Installer. Then as Jetbrains quick tutorial suggests I went to this page to download MingW-W64-builds. Installed it as x86_64. Under Toolchain | Environment clicked ... after the first dropdown slot, specified the folder called mingw64 under my installation. MinGW version should be "w64 5.0". This time no error report and Make, C compiler and C++ compiler were detected.
open the MinGW Installation Manger,and choose all the items under the path of All packages/MinGW/MinGW Base System to installation.
I keep going back to this question every now and then when I encounter the same error, although the cause of it in my cases is not present in any of the previous answers. In general, MinGW package (or CMake, whichever it is) does not like it when either it or file(s) we want it to work with is placed in a path with non-latin characters. Changing the directory of the project and / or MinGW installation solves the issue every time.

GCC /clang not present on BSD, and unable to install it

I have a freebsd 8.4 machine. I want to use to use pyinstaller to create a binary for freebsd. However it looks like pyinstaller does not support freebsd by default so i have to go in the bootloader and create stuff specific to the target system.
This is giving me errors that gcc/cc is not found on the system. Here is the first error message
Platform : FreeBSD-64bit detected
Checking for 'gcc' (C compiler) : not found
Checking for 'clang' (C compiler) : not found
So then i try to install gcc via ports. I do this
cd /usr/ports/lang/gcc49
make install
It fails :
checking whether the C compiler works... no
So i checked in the file system and there is no gcc or clang or cc. It only has ccache. Here are the details from /usr/bin
CC -> /usr/local/bin/ccache
gcc -> /usr/local/bin/ccache
There is nothing in /usr/local/bin (either CC or GCC)
so if i just do gcc at the command line i get this :
ccache: FATAL: Could not find compiler "gcc" in PATH
how do i fix this. This thing is driving me nuts. pkg install is also not working with error "No repositories found "
On FreeBSD 8.4 the standard compiler is gcc (4.2), and it's located in /usr/bin. It has to be there.
It seems that ccache installation created some problem removing/overwriting something. ccache package installs compiler links in /usr/local/libexec/ccache, but if you installed it manually I'm not sure what happened.
FreeBSD 8.4 is not maintained anymore and there's no package repository anymore for it.
My suggestion is to update your system to FreeBSD 10.2 and use clang, that's the new standard compiler.

How to build mingw32-make

I've just build a gcc 5.2.0 on windows according to this material:
http://preshing.com/20141108/how-to-install-the-latest-gcc-on-windows/
Everything went well. But then I've tried to build Qt with this newly built gcc and I'm getting an error that there is no mingw32-make. Checked directory and no, there isn't one.
But then I checked previously installed gcc, which was work of TDM, downloaded from:
http://tdm-gcc.tdragon.net/
and yes, in his build there is mingw32-make.
So, the question is, how is it that he has that tool, and many other which are absent in my build are present in his?
if you create from the gcc5.2.0 source, a build then you've just created the gcc compiler with all its necessary files. e.g. gcc-5.2.0.exe, gcc.exe, g++.exe, etc.
NOT the MinGW runtime environment for gcc, which contains the mingw32-make.exe !
if you follow your link from your question here you build it with the cygwin make.exe.
It's better to download the mingw 32 binary runtime environment for gcc
or
MinGW64 runtime environment for gcc
Then you have all the files needed to work with QT.
if you want to create a mingw build from source, you need first a MinGW runtime environment then you can use that to build your own mingw32-make.exe.

C compiler cannot create executables - Cygwin/MiniGW

I'm trying to compile Pyaudio, (a Python module) from source, since I'm using Windows, and only 32-bit binaries are available - I need 64. Following these instructions I downloaded Cygwin, and installed every component, to be safe. Installing Portaudio, another module, is required first.
When I run CFLAGS="-mno-cygwin" LDFLAGS="-mno-cygwin" ./configure, I get the error configure: error: C compiler cannot create executables. See 'config.log' for more details. config.log has an additional line below that message: gcc: The -mno-cygwin flag has been removed; use a mingw-targeted cross-compiler.
This leads me to believe that perhaps Cygwin is using the wrong compiler; the instructions are for using MinGw with Cygwin, but I never specified minigw in the process. I also wonder if there's something in the PyAudio build files that needs to be changed for 64-bit. I know nothing about C, compiling, Cygwin or MinGW, and am new to programming in general. Any ideas? Any other information I can provide?
Current versions of Cygwin gcc do not support -mno-cygwin anymore because it never really worked correctly. Instead, you should use a proper cross-compiler, which is provided by the mingw64-i686-gcc packages, then run ./configure --host=i686-w64-mingw32.
In some cases it is an antivirus that is causing problems.
I had avast and had to disable it.

Resources