Clion with MinGW not compiling simple Hello World app - gcc

I have trouble in compiling a simple hello world application with CLion and MinGW. The buttons for Run and Debug are grayd out.
I have installed MinGW with mingw32-gcc-g++ and mingw32-make packages.
After that I have install CLion which detected automatically the right folder for MinGW. However make, c compiler and c++ compiler will not get the checkmark.
Also in CMakeError.log file found the following:
Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
Compiler: C:/MinGW/bin/gcc.exe
Build flags:
Id flags:
The output was:
1
Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
Compiler: C:/MinGW/bin/gcc.exe
Build flags:
Id flags: -c
The output was:
1
Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
Compiler: C:/MinGW/bin/gcc.exe
Build flags:
Id flags: -Aa
The output was:
1
Checking whether the C compiler is IAR using "" did not match "IAR .+ Compiler":
gcc.exe: fatal error: no input files
compilation terminated.
Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
Compiler: C:/MinGW/bin/g++.exe
Build flags:
Id flags:
The output was:
1
Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
Compiler: C:/MinGW/bin/g++.exe
Build flags:
Id flags: -c
The output was:
1
Checking whether the CXX compiler is IAR using "" did not match "IAR .+ Compiler":
g++.exe: fatal error: no input files
compilation terminated.
Determining if the C compiler works failed with the following output:
Change Dir: D:/Users/Tau/.clion10/system/cmake/generated/94853116/94853116/__default__0/CMakeFiles/CMakeTmp
Run Build Command:C:/MinGW/bin/mingw32-make.exe "cmTryCompileExec3424130643/fast"
C:/MinGW/bin/mingw32-make.exe -f CMakeFiles\cmTryCompileExec3424130643.dir\build.make CMakeFiles/cmTryCompileExec3424130643.dir/build
mingw32-make.exe[1]: Entering directory 'D:/Users/Tau/.clion10/system/cmake/generated/94853116/94853116/__default__0/CMakeFiles/CMakeTmp'
"C:\Program Files (x86)\JetBrains\CLion 138.2344.17\bin\cmake\bin\cmake.exe" -E cmake_progress_report D:\Users\Tau\.clion10\system\cmake\generated\94853116\94853116\__default__0\CMakeFiles\CMakeTmp\CMakeFiles 1
Building C object CMakeFiles/cmTryCompileExec3424130643.dir/testCCompiler.c.obj
C:\MinGW\bin\gcc.exe -o CMakeFiles\cmTryCompileExec3424130643.dir\testCCompiler.c.obj -c D:\Users\Tau\.clion10\system\cmake\generated\94853116\94853116\__default__0\CMakeFiles\CMakeTmp\testCCompiler.c
CMakeFiles\cmTryCompileExec3424130643.dir\build.make:56: recipe for target 'CMakeFiles/cmTryCompileExec3424130643.dir/testCCompiler.c.obj' failed
mingw32-make.exe[1]: Leaving directory 'D:/Users/Tau/.clion10/system/cmake/generated/94853116/94853116/__default__0/CMakeFiles/CMakeTmp'
mingw32-make.exe[1]: *** [CMakeFiles/cmTryCompileExec3424130643.dir/testCCompiler.c.obj] Error 1
Makefile:113: recipe for target 'cmTryCompileExec3424130643/fast' failed
mingw32-make.exe: *** [cmTryCompileExec3424130643/fast] Error 2
I am unable to figure out. I have tried also with cygwin x64 and the same issue occurs. What is wrong?

After so much time spent without any clue, I found that actually the crashing softwares were cc1.exe and cc1plus.exe. After using Dependency Waker tool which led mo to manually adding the zlib1.dll file near these two crashing exe, I found that the real reason was that package mingw32-libz was not installed.
I have installed mingw32-libz package in MinGW and removed manually added dlls and I get all checkmarks in settings.

Related

Getting the error "make: [Makefile:2: all] Error 127" when I use the make command

I am trying to install this project onto my computer and have been running into issue after issue.
The roadblock I've run into now is error 127. Most of the install works fine, until it gets to the step "make." I get the following output:
mkdir -p build && cd build && cmake .. && make
/bin/sh: cmake: commant not found
make: *** [Makefile:2: all] Error 127
I have tried installing on Git Bash for Windows 10 and using the terminal in CentOS. Both give me the same error. I have tried installing cmake on CentOS, but I'm unsure what to do with it now that it is installed. I also installed MinGW onto the Windows machine, but with no luck.
I'm relatively new to Linux/Unix (and very new to Git) so if the answer is obvious, I apologize.
I have found other questions similar to this, but the answer is always something along the lines of "it is trying to build something and it can't. need more context"
edit: Cmake is installed (as far as I can tell). I used this walk through to install it (updating the file names and stuff to correspond with the current version of cmake). The cmake directory was installed in the Downloads directory until I moved it (details below).
Someone had suggested that the cmake wasn't in a directory accessible to the $PATH variable. I moved it into a directory that I had added to the $PATH variable a while ago, but I am still getting the same error.
Edit 2: Alright, so I installed cmake through the CentOS software app thing. The make command works now, but theres a different problem. Running the make command outputs errors. The CMakerror.log file is filled with this over and over again:
Compilling the CXX compiler identification source file "CMakeCXXComilerID.cpp" failed
Compiler: CMAKE_CXX_COMPILER-NOTFOUND
Build flags:
Id flags: -c
The output was:
No such file or directory
There are a bunhc of different entries like this, the only difference between them is that the Id flags bit sometimes has a "-c" but it also does "--c++" and "--ec++"
Edit 3: Here is the output from using the make command:
mkdir -p build && cd build && cmake .. && make
-- The CXX compiler identification is unknown
CMake Error in CMakeLists.txt:
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.
CMake Warning (dev) in CMakeLists.txt:
No cmake_minimum_required command is present. A line of code such as
cmake_minimum_required(VERSION 3.11)
should be added at the top of the file. The version specified may be lower
if you wish to support older CMake versions for this project. For more
information run "cmake --help-policy CMP0000".
This warning is for project developers. Use -Wno-dev to suppress it.
-- Configuring incomplete, errors occurred!
See also "/home/ellingtonj/wave-gui/CMakeFiles/CMakeOutput.log".
See also "/home/ellingtonj/wave-gui/CMakeFiles/CMakeError.log".
make: *** [Makefile:2: all] Error 1
I checked the CMakeLists.txt file and there is, in fact a cmake_minimum_required line (It specifically says "cmake_minimum_required (VERSION 2.8)").
Edit 4: A user below suggested I may not have gcc/g++ installed. So I used this tutorial to install gcc. Now I get error 2. Progress!! The ouput of the make command is below:
mkdir -p build && cd build && cmake .. && make
-- The CXX compiler identification is GNU 8.3.1
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Creating program 'wave-gui' with sources:
-- main.cpp
-- app.cpp
-- core.cpp
-- ui.cpp
-- data.cpp
CMake Warning (dev) in CMakeLists.txt:
No cmake_minimum_required command is present. A line of code such as
cmake_minimum_required(VERSION 3.11)
should be added at the top of the file. The version specified may be lower
if you wish to support older CMake versions for this project. For more
information run "cmake --help-policy CMP0000".
This warning is for project developers. Use -Wno-dev to suppress it.
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ellingtonj/wave-gui
make[1]: Entering directory '/home/ellingtonj/wave-gui/build'
make[1]: *** No targets specified and no makefile found. Stop.
make[1]: Leaving directory '/home/ellingtonj/wave-gui/build'
make: *** [Makefile:2: all] Error 2
Before anyone says it, yes, there is a makefile in the directory. Here is the output of ls for the directory I'm working in:
build CMakeCache.txt cmake_install.cmake external main README.md
cmake CMakeFiles CMakeLists.txt LICENSE Makefile src
Edit 5: I renamed "Makefile" on the off chance that it was looking for "makefile" and it kinda worked. I got a new error message which is good. Kinda. make ouput below:
-- Creating program 'wave-gui' with sources:
-- main.cpp
-- app.cpp
-- core.cpp
-- ui.cpp
-- data.cpp
CMake Warning (dev) in CMakeLists.txt:
No cmake_minimum_required command is present. A line of code such as
cmake_minimum_required(VERSION 3.11)
should be added at the top of the file. The version specified may be lower
if you wish to support older CMake versions for this project. For more
information run "cmake --help-policy CMP0000".
This warning is for project developers. Use -Wno-dev to suppress it.
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ellingtonj/wave-gui
Scanning dependencies of target wave-gui
[ 16%] Building CXX object CMakeFiles/wave-gui.dir/main.o
/home/ellingtonj/wave-gui/main/main.cpp:10:10: fatal error: cg_config.h: No such file or directory
#include "cg_config.h"
^~~~~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/wave-gui.dir/build.make:63: CMakeFiles/wave-gui.dir/main.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:68: CMakeFiles/wave-gui.dir/all] Error 2
make: *** [makefile:130: all] Error 2
Edit 6(?): my problem has changed so much that I figured a new thread should be made to more accurately reflect the problem I'm dealing with. This thread is located here.

resource.rc: No such file or directory

I'm setting CodeBlocks with wxWidgets, but enountered problems when compile an empty project:
resource.rc: No such file or directory
However, when I creat win32GUI project instead of wxWidgets, I could compile and run an empty GUI.
I installed CodeBlocks 17.12 on the path (D:\GreenSoft\CodeBlocks)
Add the “D:\GreenSoft\CodeBlocks\MinGW\bin” to the path environment variable.
Download the wxWidgets3.1.2 source code to “D:\GreenSoft\wxWidgets\wxWidgets312\”
cd to “D:\GreenSoft\wxWidgets\wxWidgets312\build\msw”, and run command:
mingw32-make -f makefile.gcc BUILD=release SHARED=1 MONOLITHIC=1 UNICODE=1 CXXFLAGS=-fno-keep-inline-dllexport
After compile finished, I run the OpenBlocks and add a project wxWidget with several options:
wxWidgets 3.1.*
Project Title: App
Prefered GUI builder: wxSmith
Application type: frame-based
wxWidgets location: D:\GreenSoft\wxWidgets\wxWidgets312
Compiler: GUN GCC compiler
Create Debug…
Create Release…
With three wxWidgets Library settings checked only
Then an empty GUI panel appeared in CodeBlocks.
I do nothing but click the compile button, and error appeared:
It says that
gcc: error: D:QMDownloadrmdCsrrresource.rc: No such file or directory
But I checked that the file D:\QMDownload\rmdCs\App\resource.rc exist , and its textcontent is:
aaaa ICON "wx/msw/std.ico"
include "wx/msw/wx.rc"
I have found a post with the same issue and make sure that no blank space and special character exist in all the paths, but the problem still exist.
-------------- Build: Debug in App (compiler: GNU GCC Compiler)---------------
windres.exe -ID:\GreenSoft\wxWidgets\wxWidgets312\include -ID:\GreenSoft\wxWidgets\wxWidgets312\lib\gcc_dll\mswu -J rc -O coff -i D:\QMDownload\rmdCs\App\resource.rc -o obj\Debug\resource.res
x86_64-w64-mingw32-g++.exe -LD:\GreenSoft\wxWidgets\wxWidgets312\lib\gcc_dll -o bin\Debug\App.exe obj\Debug\AppApp.o obj\Debug\AppMain.o obj\Debug\resource.res -mthreads -lwxmsw31u -mwindows
gcc: error: D:QMDownloadrmdCsAppresource.rc: No such file or directory
gcc: warning: '-x c' after last input file has no effect
gcc: fatal error: no input files
compilation terminated.
windres: preprocessing failed.
Process terminated with status 1 (0 minute(s), 0 second(s))
2 error(s), 1 warning(s) (0 minute(s), 0 second(s))

Compiling superopt on windows

I'm triing to compile the superoptimizer on windows. (https://github.com/bonzini/superopt)
Unfortunatly my knowledge of make is very limited. I tried:
make CPU=-D386 superopt
Which gives me the error:
cc superopt.c -o superopt
process_begin: CreateProcess(NULL, cc superopt.c -o superopt, ...) failed.
make (e=2): The system cannot find the file specified.
make: *** [superopt] Fehler 2
After setting the compiler to gcc manually with:
make CPU=-D386 superopt CC=gcc
I get the following error:
gcc superopt.c -o superopt
In file included from superopt.c:27:0:
superopt.h:104:2: error: #error You have to choose target CPU type (--with-arch).
#error You have to choose target CPU type (--with-arch).
^
In file included from superopt.h:130:0,
from superopt.c:27:
longlong.h:1465:14: error: unknown type name 'UQItype'
extern const UQItype __clz_tab[];
^
superopt.c:32:21: fatal error: version.h: No such file or directory
compilation terminated.
make: *** [superopt] Fehler 1
It seems it does't properly selects i386.
Any hints would be greatly appreciated.
That is not the source code of
GNU superopt. It is the source code of someone's project
to patch GNU superopt, last updated 2008, and seemingly
abandoned a hard-hat area.
This is the source code of
GNU superopt. Extract the tarball and build as you have attempted
with:
make CC=gcc CPU=-DI386 superopt
Note: I386, not 386.
You will see warnings like:
warning: incompatible implicit declaration of built-in function 'foo'
because the 20 yearold C code does not diligently include the standard
headers that prototype the standard functions that it calls, but superopt will build successfully.

error while compiling opencv for QT

i want to use opencv in QT, so i must compile it with mingw. When i want to compile it with CMake 2.8.10.2 it has following error
The CXX compiler identification is GNU 4.7.2
The C compiler identification is GNU 4.7.2
Check for working CXX compiler: C:/Qt/Qt5.0.1/Tools/MinGW/bin/g++.exe
Check for working CXX compiler: C:/Qt/Qt5.0.1/Tools/MinGW/bin/g++.exe -- broken
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeTestCXXCompiler.cmake:54 (message):
The C++ compiler "C:/Qt/Qt5.0.1/Tools/MinGW/bin/g++.exe" is not able to
compile a simple test program.
It fails with the following output:
Change Dir: C:/opencv_bin/CMakeFiles/CMakeTmp
Run Build Command:C:/Qt/Qt5.0.1/Tools/MinGW/bin/mingw32-make.exe
"cmTryCompileExec2270185098/fast"
C:/Qt/Qt5.0.1/Tools/MinGW/bin/mingw32-make.exe -f
CMakeFiles\cmTryCompileExec2270185098.dir\build.make
CMakeFiles/cmTryCompileExec2270185098.dir/build
mingw32-make.exe[1]: Entering directory
'C:/opencv_bin/CMakeFiles/CMakeTmp'
"C:\Program Files (x86)\CMake 2.8\bin\cmake.exe" -E cmake_progress_report
C:\opencv_bin\CMakeFiles\CMakeTmp\CMakeFiles 1
'C:\Users\' is not recognized as an internal or external command,
operable program or batch file.
CMakeFiles\cmTryCompileExec2270185098.dir\build.make:59: recipe for target
'CMakeFiles/cmTryCompileExec2270185098.dir/testCXXCompiler.cxx.obj' failed
mingw32-make.exe[1]: ***
[CMakeFiles/cmTryCompileExec2270185098.dir/testCXXCompiler.cxx.obj] Error
1
mingw32-make.exe[1]: Leaving directory 'C:/opencv_bin/CMakeFiles/CMakeTmp'
makefile:116: recipe for target 'cmTryCompileExec2270185098/fast' failed
mingw32-make.exe: *** [cmTryCompileExec2270185098/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:61 (project)
Configuring incomplete, errors occurred!
any idea?
I have a newer version but in my case you should try in the folder QtSDK/minGW/bin instead of Qt folder.

cmake error while running on a mounted directory

I have issue running cmake on a package residing in a mounted folder. I have full permissions on this mounted folder.
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- broken
CMake Error at /usr/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:50 (MESSAGE):
The C compiler "/usr/bin/gcc" is not able to compile a simple test program.
It fails with the following output:
Change Dir: /home/X/win_tmp/cmake/build/CMakeFiles/CMakeTmp
Run Build Command:/usr/bin/make "cmTryCompileExec/fast"
/usr/bin/make -f CMakeFiles/cmTryCompileExec.dir/build.make
CMakeFiles/cmTryCompileExec.dir/build
make: Warning: File `Makefile' has modification time 0.38 s in the future
make[1]: Entering directory
`/home/X/win_tmp/cmake/build/CMakeFiles/CMakeTmp'
make[1]: Warning: File `CMakeFiles/cmTryCompileExec.dir/flags.make' has
modification time 0.35 s in the future
/usr/bin/cmake -E cmake_progress_report
/home/X/win_tmp/cmake/build/CMakeFiles/CMakeTmp/CMakeFiles 1
Building C object CMakeFiles/cmTryCompileExec.dir/testCCompiler.c.o
/usr/bin/gcc -o CMakeFiles/cmTryCompileExec.dir/testCCompiler.c.o -c
/home/X/win_tmp/cmake/build/CMakeFiles/CMakeTmp/testCCompiler.c
cc1: error:
/home/X/win_tmp/cmake/build/CMakeFiles/CMakeTmp/testCCompiler.c:
Value too large for defined data type
make[1]: *** [CMakeFiles/cmTryCompileExec.dir/testCCompiler.c.o] Error 1
make[1]: Leaving directory
`/home/X/win_tmp/cmake/build/CMakeFiles/CMakeTmp'
make: *** [cmTryCompileExec/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:2 (project)
-- Configuring incomplete, errors occurred!
Cmake seems to run fine when I copy the package on to my linux filesystem.
Thanks,
Gudge
According to this link, the error Value too large for defined data type has to do with gcc executing stat() on Samba-mounted file systems. The inode returned is apparently rather large for those file systems.
The solution is to ensure your mount command has nounix,noserverino in the options column (in /etc/fstab or equivalent).
See the mount.cifs man page for further details.
This problem with mounted folders can also manifest itself with a failure for the cmake command "file(GLOB VAR PATTERNS)" to find anything. In my case, the subsequent command "add_library" would end up with no source files and fail with the following error:
You have called ADD_LIBRARY for library ... without any source files. This typically indicates a problem with your CMakeLists.txt file.
I hope that by mentioning this here that it will cut the search time of others from 4 to 2 minutes.

Resources