cmake error showing nonexistent folder on running in cygwin terminal - c++

I am trying to compile a c++ library g2o in cygwin(in windows 8) using cmake . I created a build folder and when I try to do cmake in that folder it fails with the following error
$ cmake ../
-- The C compiler identification is GNU 4.8.3
-- The CXX compiler identification is GNU 4.8.3
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- broken
CMake Error at /usr/share/cmake-2.8.11.2/Modules/CMakeTestCCompiler.cmake:61 (message):
The C compiler "/usr/bin/cc" is not able to compile a simple test program.
It fails with the following output:
Change Dir: /cygdrive/b/g2o/trunk/build/CMakeFiles/CMakeTmp
Run Build Command:/cygdrive/c/Program\
Files/MATLAB/R2009a/bin/win64/gmake.exe "cmTryCompileExec3795381385/fast"
C:/Program Files/MATLAB/R2009a/bin/win64/gmake -f
CMakeFiles/cmTryCompileExec3795381385.dir/build.make
CMakeFiles/cmTryCompileExec3795381385.dir/build
gmake[1]: Entering directory `B:/g2o/trunk/build/CMakeFiles/CMakeTmp'
/usr/bin/cmake.exe -E cmake_progress_report "/cygdrive/b/g2o/trunk/build/CMakeFiles/CMakeTmp/CMakeFiles" 1
Building C object
CMakeFiles/cmTryCompileExec3795381385.dir/testCCompiler.c.o
/usr/bin/cc -o CMakeFiles/cmTryCompileExec3795381385.dir/testCCompiler.c.o
-c "/cygdrive/b/g2o/trunk/build/CMakeFiles/CMakeTmp/testCCompiler.c"
Linking C executable cmTryCompileExec3795381385.exe
/usr/bin/cmake.exe -E cmake_link_script
CMakeFiles/cmTryCompileExec3795381385.dir/link.txt --verbose=1
gmake[1]: Leaving directory `B:/g2o/trunk/build/CMakeFiles/CMakeTmp'
process_begin: CreateProcess(NULL, /usr/bin/cmake.exe -E cmake_link_script
CMakeFiles/cmTryCompileExec3795381385.dir/link.txt --verbose=1, ...)
failed.
make (e=2): The system cannot find the file specified.
gmake[1]: *** [cmTryCompileExec3795381385.exe] Error 2
gmake: *** [cmTryCompileExec3795381385/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:4 (PROJECT)
-- Configuring incomplete, errors occurred!
The interesting thing here is I have cmake 3.0 installed in my machine and the error says cmake 2.8.11.2. I did a search in the pc and cannot find any folder by that name. The system path variable contains the path to correct cmake bin folder also.
I cannot figure out what could be the reason behind this error. Can it be an issue with the cygwin itself? What can I do to avoid this error?

One thing to note, Cygwin has its own copy of CMake, which is what your seeing as 2.8.11.2. That version has nothing to do with the one you have on your Windows machine. Have you tried to use the Windows installed version and not Cygwin?
I think the problem comes from not having all required compiler libraries installed in Cygwin. You could try creating a simple C++ file and try compiling it with gcc directly. If that fails, you've now found out why CMake is failing.
Unless there is a good reason to do so, you should probably consider NOT using Cygwin to run CMake inside Windows. CMake is very capable of producing Visual Studio project files.

The issue, at least for me, was the c compiler not accepting unix style paths.
The solution was to install gcc via cygwin. The packages I installed is gcc-base and gcc-cpp I believe.

Related

"'MinGW/bin/gcc.exe' is not able to compile a simple test program."

I am currently learning CMake. Right now I am trying to configure CMake to build an example program to learn the basics, but I can't get past what seems like something that should be really easy. It seems that CMake does not agree with my gcc and g++ compilers. I have installed them through CodeBlocks, and they work fine there. However, when I go to configure a project in the CMake GUI I get the following:
The C compiler identification is unknown
The CXX compiler identification is unknown
Check for working C compiler: C:/CodeBlocks/MinGW/bin/gcc.exe
Check for working C compiler: C:/CodeBlocks/MinGW/bin/gcc.exe -- broken
CMake Error at C:/Program Files/CMake/share/cmake-3.15/Modules/CMakeTestCCompiler.cmake:60 (message):
The C compiler
"C:/CodeBlocks/MinGW/bin/gcc.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/Users/Bank/Desktop/Introductions-to-Libraries-with-CMake/Build/CMakeFiles/CMakeTmp
Run Build Command(s):C:/MinGW/bin/mingw32-make.exe cmTC_52744/fast && C:/MinGW/bin/mingw32-make.exe -f CMakeFiles\cmTC_52744.dir\build.make CMakeFiles/cmTC_52744.dir/build
mingw32-make.exe[1]: Entering directory 'C:/Users/Bank/Desktop/Introductions-to-Libraries-with-CMake/Build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_52744.dir/testCCompiler.c.obj
C:\CodeBlocks\MinGW\bin\gcc.exe -o CMakeFiles\cmTC_52744.dir\testCCompiler.c.obj -c C:\Users\Bank\Desktop\Introductions-to-Libraries-with-CMake\Build\CMakeFiles\CMakeTmp\testCCompiler.c
CMakeFiles\cmTC_52744.dir\build.make:64: recipe for target 'CMakeFiles/cmTC_52744.dir/testCCompiler.c.obj' failed
mingw32-make.exe[1]: *** [CMakeFiles/cmTC_52744.dir/testCCompiler.c.obj] Error 1
mingw32-make.exe[1]: Leaving directory 'C:/Users/Bank/Desktop/Introductions-to-Libraries-with-CMake/Build/CMakeFiles/CMakeTmp'
Makefile:120: recipe for target 'cmTC_52744/fast' failed
mingw32-make.exe: *** [cmTC_52744/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:/Users/Bank/Desktop/Introductions-to-Libraries-with-CMake/Build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/Bank/Desktop/Introductions-to-Libraries-with-CMake/Build/CMakeFiles/CMakeError.log".
Here is my CMakeLists file:
cmake_minimum_required(VERSION 3.0.0)
set(CMAKE_C_COMPILER "C:/CodeBlocks/MinGW/bin/gcc.exe")
set(CMAKE_CXX_COMPILER "C:/CodeBlocks/MinGW/bin/g++.exe")
project("Foo")
add_subdirectory("foo")
And if it helps, here is what the Path variable in my Environment Variables looks like:
C:\Program Files (x86)\Common Files\Oracle\Java\javapath;c:\windows\system32;c:\windows;c:\windows\system32\wbem;c:\windows\system32\windowspowershell\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Git;C:\Program Files\Git\cmd;C:\Users\Bank\AppData\Local\Android\Sdk\tools;C:\Users\Bank\AppData\Local\Android\Sdk\platform-tools;C:\Users\Bank\Desktop\sfAnd\android-ndk-r20;C:\Program Files\CMake\bin;C:\Program Files\Java\jdk1.8.0_231;C:\MinGW\msys\1.0\bin;C:\Program Files\Java\jdk1.8.0_231\jre;C:\Gradle\gradle-6.0-all\gradle-6.0\bin;C:\Gradle\gradle-6.0-all\gradle-6.0;C:\Program Files (x86)\GnuWin32\bin;I:\Storage\Programs\apache-ant-1.9.14-bin\apache-ant-1.9.14\bin;C:\Python27;C:\ninja-win;C:\Program Files\dotnet\;C:\CodeBlocks\MinGW
What could the problem be?
C:\CodeBlocks\MinGW probably doesn't contain the DLL's to gcc or g++. You should add C:\CodeBlocks\MinGW\bin and/or C:\CodeBlocks\MinGW\lib to your path instead, depending on how MinGW was installed. I use MSys2 and use the provided environment for 32bit and 64bit tools. I try to get rid of the pre-packaged versions of MinGW to avoid confusion on my own computers (I noticed msys 1.0 in your path).
I figured it out, finally, thanks to this post:
Cmake build error for c++
I read some posts that said "[your_path]\MinGW" needed to be in your PATH variable, but it's actually "[your_path]\MinGW\bin." I am still not sure why adding the following in CMakeLists did not work:
set(CMAKE_C_COMPILER "C:/CodeBlocks/MinGW/bin/gcc.exe")
set(CMAKE_CXX_COMPILER "C:/CodeBlocks/MinGW/bin/g++.exe")
but that's for another time. Thank you for your help.

Can't get CMAKE to compile a project

Here's the error I'm getting:
-- Building for: NMake Makefiles
-- The C compiler identification is GNU 4.8.1
-- The CXX compiler identification is GNU 4.8.1
-- Check for working C compiler: C:/MinGW/bin/gcc.exe
CMake Error: Generator: execution of make failed. Make command was: "nmake" "/NOLOGO" "cmTC_86068\fast"
-- Check for working C compiler: C:/MinGW/bin/gcc.exe -- broken
CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.4/Modules/CMakeTestCCompiler.cmake:61 (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:/--REDACTED--/CMakeFiles/CMakeTmp
Run Build Command:"nmake" "/NOLOGO" "cmTC_86068\fast"
The system cannot find the file specified
Generator: execution of make failed. Make command was: "nmake" "/NOLOGO" "cmTC_86068\fast"
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:2 (PROJECT)
-- Configuring incomplete, errors occurred!
See also "C:/--REDACTED--/socket.io-client-cpp-1.6.1/CMakeFiles/CMakeOutput.log".
See also "C:/--REDACTED--/socket.io-client-cpp-1.6.1/CMakeFiles/CMakeError.log".
For the record I am using:
gcc and g++ from MinGW 4.8.1
CMake 3.4.1
I have no idea what the issue could be, I've looked extensively online and have not found anywhere where somebody has gotten a solution, except in cases where it had to do with path issues where the path included non-latin characters or no write access, which is not the case for any of the directories in question. I seriously am about to give up completely on ever being able to get this to work, but I don't know what to do because I absolutely NEED the socket.io client for C++ for this project.
CMake is a utility which generates a "makefile" for different build systems. Here you generate a nmake makefile and it seems that you don't have nmake in your path.
You can launch CMake with option -G "MinGW Makefiles" in order to generate a makefile compatible with mingw make. Then issue the command:
mingw32-make

how to get cmake to use the gnu stack of tools under msys2 (mingw)

On Windows 10, with an installed msys2, which is a variant of mingw, I have an installed cmake with the gcc toolchain and all the standard tools like make.
The version of g++ is 6.2 and make is 4.2.1 Both are in the path.
When I build using cmake:
cmake .
it tries to build using nmake and cl. So somehow because I am on windows cmake is trying to use the visual studio toolchain.
export CMAKE_CXX_COMPILER=g++
does not help. The error is:
-- Building for: NMake Makefiles
-- The C compiler identification is unknown
-- The CXX compiler identification is Clang 3.8.0
-- Check for working C compiler: D:/msys64/mingw64/bin/clang++.exe
CMake Error: Generator: execution of make failed. Make command was: "nmake" "/NOLOGO" "cmTC_87e5f\fast"
-- Check for working C compiler: D:/msys64/mingw64/bin/clang++.exe -- broken
CMake Error at D:/msys64/mingw64/share/cmake-3.6/Modules/CMakeTestCCompiler.cmake:61 (message):
The C compiler "D:/msys64/mingw64/bin/clang++.exe" is not able to compile a
simple test program.
It fails with the following output:
Change Dir: D:/git/CSP/CMakeFiles/CMakeTmp
Run Build Command:"nmake" "/NOLOGO" "cmTC_87e5f\fast"
Generator: execution of make failed. Make command was: "nmake" "/NOLOGO"
"cmTC_87e5f\fast"
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:2 (project)
-- Configuring incomplete, errors occurred!
See also "D:/git/CSP/CMakeFiles/CMakeOutput.log".
See also "D:/git/CSP/CMakeFiles/CMakeError.log".
To use MSYS2 toolchain, you need to specify the build system generator explicitly, i.e.
cmake -G 'MSYS Makefiles' .
Additional note, it's a good practice to separate the application . source file and cmake's generated file, e.g.
mkdir build
cd build
cmake -G 'MSYS Makefiles' ..

Cmake errors: The CXX Compiler identification is unknown, The C compiler identification is unknown

I'm trying to install OpenCV on Fedora 21 with a cross compiler for ARM processor.
However, when i try to configure using Cmake 3.03, it gives the error:
*The CXX compiler identification is unknown
The C compiler identification is unknown
Check for working CXX compiler: /opt/FriendlyARM/toolschain/4.5.1/bin/arm-linux-g++
Check for working CXX compiler: /opt/FriendlyARM/toolschain/4.5.1/bin/arm-linux-g++ -- broken
CMake Error at /usr/share/cmake/Modules/CMakeTestCXXCompiler.cmake:54 (message):
The C++ compiler "/opt/FriendlyARM/toolschain/4.5.1/bin/arm-linux-g++" is
not able to compile a simple test program.
It fails with the following output:
Change Dir: /opt/opencv/relarm/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/gmake" "cmTryCompileExec1616328985/fast"
/usr/bin/gmake -f CMakeFiles/cmTryCompileExec1616328985.dir/build.make
CMakeFiles/cmTryCompileExec1616328985.dir/build
gmake[1]: Entering directory '/opt/opencv/relarm/CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report
/opt/opencv/relarm/CMakeFiles/CMakeTmp/CMakeFiles 1
Building CXX object
CMakeFiles/cmTryCompileExec1616328985.dir/testCXXCompiler.cxx.o
/opt/FriendlyARM/toolschain/4.5.1/bin/arm-linux-g++ -o
CMakeFiles/cmTryCompileExec1616328985.dir/testCXXCompiler.cxx.o -c
/opt/opencv/relarm/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
/opt/FriendlyARM/toolschain/4.5.1/lib/gcc/arm-none-linux-gnueabi/4.5.1/../../../../arm-none-linux-gnueabi/bin/as:
error while loading shared libraries: libz.so.1: cannot open shared object
file: No such file or directory
CMakeFiles/cmTryCompileExec1616328985.dir/build.make:57: recipe for target
'CMakeFiles/cmTryCompileExec1616328985.dir/testCXXCompiler.cxx.o' failed
gmake[1]: Leaving directory '/opt/opencv/relarm/CMakeFiles/CMakeTmp'
gmake[1]: ***
[CMakeFiles/cmTryCompileExec1616328985.dir/testCXXCompiler.cxx.o] Error 1
Makefile:118: recipe for target 'cmTryCompileExec1616328985/fast' failed
gmake: *** [cmTryCompileExec1616328985/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:63 (project)
Configuring incomplete, errors occurred!
See also "/opt/opencv/relarm/CMakeFiles/CMakeOutput.log".
See also "/opt/opencv/relarm/CMakeFiles/CMakeError.log".*
I tried adding Path to my bash_profile, so that it looks like this:
# .bash_profile
# Get the aliases and functions if [ -f ~/.bashrc ]; then
. ~/.bashrc fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin export PATH=$PATH:/usr/local/bin:/usr/local/sbin:/opt/FriendlyARM/toolschain/4.5.1/bin/arm-linux-g++:/usr/bin/gmake:/usr/share/bin:/usr/share/sbin
I Have been googling around for hours but couldn't find any helpful steps. Any help would be appreciated.
Thanks in advance.
From the output it appears that cmake was able to find your cross compiler but as the output says it can't compile a simple program. I would start with creating Hello World in C++ and trying to compile that with your cross compiler. If that doesn't work that is your first problem. If it does work then I would guess it has to do with some environment variable(s). You could try to have cmake print the environment variables before it tries to compile the simple C++ program and compare to your shell environment variables, sorry I can't be more helpful than that.
Update:
So I downloaded FriendlyArm and the binaries it provides are 32 bit ELF's so you will need the 32 bit version of libz. A yum install zlib.i686 should solve your issue. The FriendlyArm toolchain works for me and I have zlib.i686 installed already. If you get any other errors about missing shared objects make sure you have the 32 bit version installed.

CMake "clang++ is not able compile a simple test program" (Fedora 20)

So I tried to install clang + cmake to compile a simple C++ program and I'm getting the following error:
-- The C compiler identification is GNU 4.8.3
-- The CXX compiler identification is Clang 3.5.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/local/bin/clang++
-- Check for working CXX compiler: /usr/local/bin/clang++ -- broken
CMake Error at /usr/share/cmake/Modules/CMakeTestCXXCompiler.cmake:54 (message):
The C++ compiler "/usr/local/bin/clang++" is not able to compile a simple
test program.
It fails with the following output:
Change Dir: /home/jtcwang/tmp/CMake/CMake/CMakeFiles/CMakeTmp
Run Build Command:/usr/bin/gmake "cmTryCompileExec697180971/fast"
/usr/bin/gmake -f CMakeFiles/cmTryCompileExec697180971.dir/build.make
CMakeFiles/cmTryCompileExec697180971.dir/build
gmake[1]: Entering directory
`/home/jtcwang/tmp/CMake/CMake/CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report
/home/jtcwang/tmp/CMake/CMake/CMakeFiles/CMakeTmp/CMakeFiles 1
Building CXX object
CMakeFiles/cmTryCompileExec697180971.dir/testCXXCompiler.cxx.o
/usr/local/bin/clang++ -o
CMakeFiles/cmTryCompileExec697180971.dir/testCXXCompiler.cxx.o -c
/home/jtcwang/tmp/CMake/CMake/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
Linking CXX executable cmTryCompileExec697180971
/usr/bin/cmake -E cmake_link_script
CMakeFiles/cmTryCompileExec697180971.dir/link.txt --verbose=1
/usr/local/bin/clang++
CMakeFiles/cmTryCompileExec697180971.dir/testCXXCompiler.cxx.o -o
cmTryCompileExec697180971 -rdynamic
/usr/bin/ld: cannot find -lstdc++
clang: error: linker command failed with exit code 1 (use -v to see
invocation)
gmake[1]: Leaving directory
`/home/jtcwang/tmp/CMake/CMake/CMakeFiles/CMakeTmp'
gmake[1]: *** [cmTryCompileExec697180971] Error 1
gmake: *** [cmTryCompileExec697180971/fast] Error 2
It's not even compiling my program because it fails to compile a test program.
Looks like the important line is here:
/usr/bin/ld: cannot find -lstdc++
However, I have checked that libstdc++ is installed and up to date, so at this point I'm quite lost.
Other things I've tried:
Using prebuilt binaries instead of sudo yum install clang
remove and reinstall
Tried clang++ hello.cpp (hello world program). It says <iostreams> is not found. Is clang missing a standard library? EDIT: changing to <iostream> gives me the same linker error above.
I'm not familiar with the clang, cmake and C++ scene in general, so I'd appreciate any pointers. Thanks!
You need the development libraries and headers for C++ library, try
yum install libstdc++-devel
Your /home/gnu/bin/c++ seem to require additional flag to link things properly and CMake doesn't know about that.
To use /usr/bin/c++ as your compiler run cmake with -DCMAKE_CXX_COMPILER=/usr/bin/c++.
Also, CMAKE_PREFIX_PATH variable sets destination dir where your project' files should be installed. It has nothing to do with CMake installation prefix and CMake itself already know this.