Cmake/Mingw32: cmake command fails - testCCompiler.c not found - c++

I have a problem while running cmake with a mingw32 custom compiler in a cygwin terminal.
I have already tried several approaches to fix my problem, until I got to the point where it only fails on finding testCCompiler.c from the directory CmakeTmp.
When I try to manually make the temporary files after cmake failed, the make command runs successfully. (Used --debug-trycompile to keep temporary files)
This is the output from the CMakeError.log file:
Determining if the C compiler works failed with the following output:
Change Dir: /cygdrive/d/programming/cpp/T2D/build/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make.exe" "cmTC_5e0c4/fast"
/usr/bin/make -f CMakeFiles/cmTC_5e0c4.dir/build.make CMakeFiles/cmTC_5e0c4.dir/build
make[1]: Verzeichnis „/cygdrive/d/programming/cpp/T2D/build/CMakeFiles/CMakeTmp“ wird betreten
Building C object CMakeFiles/cmTC_5e0c4.dir/testCCompiler.c.o
/opt/mingw32-1.6.0/bin/i686-w64-mingw32-gcc-6.1.0.exe -o CMakeFiles/cmTC_5e0c4.dir/testCCompiler.c.o -c /cygdrive/d/programming/cpp/T2D/build/CMakeFiles/CMakeTmp/testCCompiler.c
i686-w64-mingw32-gcc-6.1.0.exe: error: /cygdrive/d/programming/cpp/T2D/build/CMakeFiles/CMakeTmp/testCCompiler.c: No such file or directory
i686-w64-mingw32-gcc-6.1.0.exe: fatal error: no input files
compilation terminated.
make[1]: *** [CMakeFiles/cmTC_5e0c4.dir/build.make:66: CMakeFiles/cmTC_5e0c4.dir/testCCompiler.c.o] Fehler 1
make[1]: Verzeichnis „/cygdrive/d/programming/cpp/T2D/build/CMakeFiles/CMakeTmp“ wird verlassen
make: *** [Makefile:126: cmTC_5e0c4/fast] Fehler 2
As I see it, the file testCCompiler.c is missing while running gcc-6.1.0.
But when I compile it manually after cmake has failed, it runs successfully. When I run make in the specific directory it works as well (BUT: compiler identification is 6.4.0 while my custom compiler id is 6.1.0).
Running mingw32-make manually for testCCompiler.c:
/usr/bin/cmake.exe -H/cygdrive/d/programming/cpp/T2D/build/CMakeFiles/CMakeTmp -B/cygdrive/d/programming/cpp/T2D/build/CMakeFiles/CMakeTmp --check-build-system CMakeFiles/Makefile.cmake 0
-- The C compiler identification is GNU 6.4.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
-- Detecting C compile features
-- Detecting C compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /cygdrive/d/programming/cpp/T2D/build/CMakeFiles/CMakeTmp
/usr/bin/cmake.exe -E cmake_progress_start /cygdrive/d/programming/cpp/T2D/build/CMakeFiles/CMakeTmp/CMakeFiles /cygdrive/d/programming/cpp/T2D/build/CMakeFiles/CMakeTmp/CMakeFiles/progress.marks
C:/Cygwin/opt/mingw32-1.6.0/bin/mingw32-make -f CMakeFiles/Makefile2 all
mingw32-make[1]: Entering directory 'D:/programming/cpp/T2D/build/CMakeFiles/CMakeTmp'
C:/Cygwin/opt/mingw32-1.6.0/bin/mingw32-make -f CMakeFiles/cmTC_033c1.dir/build.make CMakeFiles/cmTC_033c1.dir/depend
mingw32-make[2]: Entering directory 'D:/programming/cpp/T2D/build/CMakeFiles/CMakeTmp'
cd /cygdrive/d/programming/cpp/T2D/build/CMakeFiles/CMakeTmp && /usr/bin/cmake.exe -E cmake_depends "Unix Makefiles" /cygdrive/d/programming/cpp/T2D/build/CMakeFiles/CMakeTmp /cygdrive/d/programming/cpp/T2D/build/CMakeFiles/CMakeTmp /cygdrive/d/programming/cpp/T2D/build/CMakeFiles/CMakeTmp /cygdrive/d/programming/cpp/T2D/build/CMakeFiles/CMakeTmp /cygdrive/d/programming/cpp/T2D/build/CMakeFiles/CMakeTmp/CMakeFiles/cmTC_033c1.dir/DependInfo.cmake --color=
Scanning dependencies of target cmTC_033c1
mingw32-make[2]: Leaving directory 'D:/programming/cpp/T2D/build/CMakeFiles/CMakeTmp'
C:/Cygwin/opt/mingw32-1.6.0/bin/mingw32-make -f CMakeFiles/cmTC_033c1.dir/build.make CMakeFiles/cmTC_033c1.dir/build
mingw32-make[2]: Entering directory 'D:/programming/cpp/T2D/build/CMakeFiles/CMakeTmp'
[ 50%] Building C object CMakeFiles/cmTC_033c1.dir/testCCompiler.c.o
/usr/bin/cc -o CMakeFiles/cmTC_033c1.dir/testCCompiler.c.o -c /cygdrive/d/programming/cpp/T2D/build/CMakeFiles/CMakeTmp/testCCompiler.c
[100%] Linking C executable cmTC_033c1.exe
/usr/bin/cmake.exe -E cmake_link_script CMakeFiles/cmTC_033c1.dir/link.txt --verbose=1
/usr/bin/cc -Wl,--enable-auto-import CMakeFiles/cmTC_033c1.dir/testCCompiler.c.o -o cmTC_033c1.exe -Wl,--out-implib,libcmTC_033c1.dll.a -Wl,--major-image-version,0,--minor-image-version,0
mingw32-make[2]: Leaving directory 'D:/programming/cpp/T2D/build/CMakeFiles/CMakeTmp'
[100%] Built target cmTC_033c1
mingw32-make[1]: Leaving directory 'D:/programming/cpp/T2D/build/CMakeFiles/CMakeTmp'
/usr/bin/cmake.exe -E cmake_progress_start /cygdrive/d/programming/cpp/T2D/build/CMakeFiles/CMakeTmp/CMakeFiles 0
My top level CMakeLists.txt is just a simple one, for testing my toolchain configuration:
cmake_minimum_required(VERSION 2.8)
project(T2D)
add_executable(T2D main.cpp)
The cmake command is in a seperate bash file and looks like this:
cmake .. --debug-trycompile -DCMAKE_C_COMPILER=i686-w64-mingw32-gcc-6.1.0 \
-DCMAKE_CXX_COMPILER=i686-w64-mingw32-g++ \
-DCMAKE_LIBRARY_PATH="/opt/mingw32-1.6.0/lib/gcc/i686-w64-mingw32/6.1.0 /opt/mingw32-1.6.0/i686-w64-mingw32/lib" \
-DCMAKE_INCLUDE_PATH="/opt/mingw32-1.6.0/lib/gcc/i686-w64-mingw32/6.1.0/include /opt/mingw32-1.6.0/lib/gcc/i686-w64-mingw32/6.1.0/include-fixed /opt/mingw32-1.6.0/lib/gcc/i686-w64-mingw32/6.1.0/include/c++ /opt/mingw32-1.6.0/i686-w64-mingw32/include/"
Does anyone see what's going wrong, besides the wrong compiler identification? (How does that happen anyway? I've already tried setting the CC and CXX vars too, but that still doesnt change anything; make and mingw32-make still always use 6.4.0 instead of 6.1.0)

Related

Unable to make ROS2 package (but used to be able to)

I am having trouble making a ros2 package for the Robotis Open manipulator. I was able to run this and am able to run this on a virtual machine, but my main machine is now not able to build these packages anymore. I have reinstall foxy a number of times and the results are still the same.
These are the commands I am using:
colcon build --event-handlers console_direct+ --cmake-args -DCMAKE_VERBOSE_MAKEFILE=ON --packages-select dynamixel_sdk_custom_interfaces
Although a simple colcon build also gives me the same errors I wanted to see if making it verbose would help me identify the issue.
Here are the results I got:
Starting >>> dynamixel_sdk_custom_interfaces
-- The C compiler identification is GNU 9.4.0
-- The CXX compiler identification is GNU 9.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found ament_cmake: 0.9.9 (/opt/ros/foxy/share/ament_cmake/cmake)
-- Found PythonInterp: /usr/bin/python3 (found suitable version "3.8.10", minimum required is "3")
-- Using PYTHON_EXECUTABLE: /usr/bin/python3
-- Found builtin_interfaces: 1.0.0 (/opt/ros/foxy/share/builtin_interfaces/cmake)
-- Using all available rosidl_typesupport_c: rosidl_typesupport_fastrtps_c;rosidl_typesupport_introspection_c
-- Found rosidl_adapter: 1.2.1 (/opt/ros/foxy/share/rosidl_adapter/cmake)
-- Found OpenSSL: /usr/lib/x86_64-linux-gnu/libcrypto.so (found version "1.1.1f")
-- Found FastRTPS: /opt/ros/foxy/include
-- Using all available rosidl_typesupport_cpp: rosidl_typesupport_fastrtps_cpp;rosidl_typesupport_introspection_cpp
-- Found rosidl_default_generators: 1.0.1 (/opt/ros/foxy/share/rosidl_default_generators/cmake)
-- Found PythonInterp: /usr/bin/python3 (found version "3.8.10")
-- Found ament_cmake_ros: 0.9.2 (/opt/ros/foxy/share/ament_cmake_ros/cmake)
-- Using all available rosidl_typesupport_c: rosidl_typesupport_fastrtps_c;rosidl_typesupport_introspection_c
-- Using all available rosidl_typesupport_cpp: rosidl_typesupport_fastrtps_cpp;rosidl_typesupport_introspection_cpp
-- Found PythonInterp: /usr/bin/python3 (found suitable version "3.8.10", minimum required is "3.5")
-- Found python_cmake_module: 0.8.1 (/opt/ros/foxy/share/python_cmake_module/cmake)
-- Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython3.8.so (found suitable version "3.8.10", minimum required is "3.5")
-- Using PYTHON_EXECUTABLE: /usr/bin/python3
-- Using PYTHON_INCLUDE_DIRS: /usr/include/python3.8
-- Using PYTHON_LIBRARIES: /usr/lib/x86_64-linux-gnu/libpython3.8.so
-- Found PythonExtra: .so
-- Configuring done
-- Generating done
-- Build files have been written to: /home/mainuser/colcon_ws/build/dynamixel_sdk_custom_interfaces
/usr/bin/cmake -S/home/mainuser/colcon_ws/src/DynamixelSDK/dynamixel_sdk_custom_interfaces -B/home/mainuser/colcon_ws/build/dynamixel_sdk_custom_interfaces --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/mainuser/colcon_ws/build/dynamixel_sdk_custom_interfaces/CMakeFiles /home/mainuser/colcon_ws/build/dynamixel_sdk_custom_interfaces//CMakeFiles/progress.marks
/usr/bin/make -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/home/mainuser/colcon_ws/build/dynamixel_sdk_custom_interfaces'
/usr/bin/make -f CMakeFiles/dynamixel_sdk_custom_interfaces__cpp.dir/build.make CMakeFiles/dynamixel_sdk_custom_interfaces__cpp.dir/depend
/usr/bin/make -f CMakeFiles/dynamixel_sdk_custom_interfaces__rosidl_generator_c.dir/build.make CMakeFiles/dynamixel_sdk_custom_interfaces__rosidl_generator_c.dir/depend
make[1]: *** No rule to make target 'dynamixel_sdk_custom_interfaces__py/CMakeFiles/dynamixel_sdk_custom_interfaces__py.dir/all', needed by 'CMakeFiles/dynamixel_sdk_custom_interfaces__python.dir/all'. Stop.
make[1]: *** Waiting for unfinished jobs....
make[2]: Entering directory '/home/mainuser/colcon_ws/build/dynamixel_sdk_custom_interfaces'
cd /home/mainuser/colcon_ws/build/dynamixel_sdk_custom_interfaces && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/mainuser/colcon_ws/src/DynamixelSDK/dynamixel_sdk_custom_interfaces /home/mainuser/colcon_ws/src/DynamixelSDK/dynamixel_sdk_custom_interfaces /home/mainuser/colcon_ws/build/dynamixel_sdk_custom_interfaces /home/mainuser/colcon_ws/build/dynamixel_sdk_custom_interfaces /home/mainuser/colcon_ws/build/dynamixel_sdk_custom_interfaces/CMakeFiles/dynamixel_sdk_custom_interfaces__cpp.dir/DependInfo.cmake --color=
make[2]: Entering directory '/home/mainuser/colcon_ws/build/dynamixel_sdk_custom_interfaces'
[ 2%] Generating C code for ROS interfaces
/usr/bin/python3 /opt/ros/foxy/share/rosidl_generator_c/cmake/../../../lib/rosidl_generator_c/rosidl_generator_c --generator-arguments-file /home/mainuser/colcon_ws/build/dynamixel_sdk_custom_interfaces/rosidl_generator_c__arguments.json
make[2]: Leaving directory '/home/mainuser/colcon_ws/build/dynamixel_sdk_custom_interfaces'
/usr/bin/make -f CMakeFiles/dynamixel_sdk_custom_interfaces__cpp.dir/build.make CMakeFiles/dynamixel_sdk_custom_interfaces__cpp.dir/build
make[2]: Entering directory '/home/mainuser/colcon_ws/build/dynamixel_sdk_custom_interfaces'
[ 5%] Generating C++ code for ROS interfaces
/usr/bin/python3 /opt/ros/foxy/share/rosidl_generator_cpp/cmake/../../../lib/rosidl_generator_cpp/rosidl_generator_cpp --generator-arguments-file /home/mainuser/colcon_ws/build/dynamixel_sdk_custom_interfaces/rosidl_generator_cpp__arguments.json
make[2]: Leaving directory '/home/mainuser/colcon_ws/build/dynamixel_sdk_custom_interfaces'
[ 5%] Built target dynamixel_sdk_custom_interfaces__cpp
cd /home/mainuser/colcon_ws/build/dynamixel_sdk_custom_interfaces && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/mainuser/colcon_ws/src/DynamixelSDK/dynamixel_sdk_custom_interfaces /home/mainuser/colcon_ws/src/DynamixelSDK/dynamixel_sdk_custom_interfaces /home/mainuser/colcon_ws/build/dynamixel_sdk_custom_interfaces /home/mainuser/colcon_ws/build/dynamixel_sdk_custom_interfaces /home/mainuser/colcon_ws/build/dynamixel_sdk_custom_interfaces/CMakeFiles/dynamixel_sdk_custom_interfaces__rosidl_generator_c.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/mainuser/colcon_ws/build/dynamixel_sdk_custom_interfaces'
/usr/bin/make -f CMakeFiles/dynamixel_sdk_custom_interfaces__rosidl_generator_c.dir/build.make CMakeFiles/dynamixel_sdk_custom_interfaces__rosidl_generator_c.dir/build
make[2]: Entering directory '/home/mainuser/colcon_ws/build/dynamixel_sdk_custom_interfaces'
[ 10%] Building C object CMakeFiles/dynamixel_sdk_custom_interfaces__rosidl_generator_c.dir/rosidl_generator_c/dynamixel_sdk_custom_interfaces/srv/detail/get_position__functions.c.o
[ 10%] Building C object CMakeFiles/dynamixel_sdk_custom_interfaces__rosidl_generator_c.dir/rosidl_generator_c/dynamixel_sdk_custom_interfaces/msg/detail/set_position__functions.c.o
/usr/bin/cc -DRCUTILS_ENABLE_FAULT_INJECTION -DROS_PACKAGE_NAME=\"dynamixel_sdk_custom_interfaces\" -Ddynamixel_sdk_custom_interfaces__rosidl_generator_c_EXPORTS -I/home/mainuser/colcon_ws/build/dynamixel_sdk_custom_interfaces/rosidl_generator_c -isystem /opt/ros/foxy/include -fPIC -Wall -std=gnu11 -MD -MT CMakeFiles/dynamixel_sdk_custom_interfaces__rosidl_generator_c.dir/rosidl_generator_c/dynamixel_sdk_custom_interfaces/msg/detail/set_position__functions.c.o -MF CMakeFiles/dynamixel_sdk_custom_interfaces__rosidl_generator_c.dir/rosidl_generator_c/dynamixel_sdk_custom_interfaces/msg/detail/set_position__functions.c.o.d -o CMakeFiles/dynamixel_sdk_custom_interfaces__rosidl_generator_c.dir/rosidl_generator_c/dynamixel_sdk_custom_interfaces/msg/detail/set_position__functions.c.o -c /home/mainuser/colcon_ws/build/dynamixel_sdk_custom_interfaces/rosidl_generator_c/dynamixel_sdk_custom_interfaces/msg/detail/set_position__functions.c
/usr/bin/cc -DRCUTILS_ENABLE_FAULT_INJECTION -DROS_PACKAGE_NAME=\"dynamixel_sdk_custom_interfaces\" -Ddynamixel_sdk_custom_interfaces__rosidl_generator_c_EXPORTS -I/home/mainuser/colcon_ws/build/dynamixel_sdk_custom_interfaces/rosidl_generator_c -isystem /opt/ros/foxy/include -fPIC -Wall -std=gnu11 -MD -MT CMakeFiles/dynamixel_sdk_custom_interfaces__rosidl_generator_c.dir/rosidl_generator_c/dynamixel_sdk_custom_interfaces/srv/detail/get_position__functions.c.o -MF CMakeFiles/dynamixel_sdk_custom_interfaces__rosidl_generator_c.dir/rosidl_generator_c/dynamixel_sdk_custom_interfaces/srv/detail/get_position__functions.c.o.d -o CMakeFiles/dynamixel_sdk_custom_interfaces__rosidl_generator_c.dir/rosidl_generator_c/dynamixel_sdk_custom_interfaces/srv/detail/get_position__functions.c.o -c /home/mainuser/colcon_ws/build/dynamixel_sdk_custom_interfaces/rosidl_generator_c/dynamixel_sdk_custom_interfaces/srv/detail/get_position__functions.c
[ 12%] Linking C shared library libdynamixel_sdk_custom_interfaces__rosidl_generator_c.so
/usr/bin/cmake -E cmake_link_script CMakeFiles/dynamixel_sdk_custom_interfaces__rosidl_generator_c.dir/link.txt --verbose=1
/usr/bin/cc -fPIC -shared -Wl,-soname,libdynamixel_sdk_custom_interfaces__rosidl_generator_c.so -o libdynamixel_sdk_custom_interfaces__rosidl_generator_c.so CMakeFiles/dynamixel_sdk_custom_interfaces__rosidl_generator_c.dir/rosidl_generator_c/dynamixel_sdk_custom_interfaces/msg/detail/set_position__functions.c.o CMakeFiles/dynamixel_sdk_custom_interfaces__rosidl_generator_c.dir/rosidl_generator_c/dynamixel_sdk_custom_interfaces/srv/detail/get_position__functions.c.o -Wl,-rpath,/opt/ros/foxy/lib: /opt/ros/foxy/lib/libbuiltin_interfaces__rosidl_typesupport_introspection_c.so /opt/ros/foxy/lib/libbuiltin_interfaces__rosidl_typesupport_c.so /opt/ros/foxy/lib/libbuiltin_interfaces__rosidl_typesupport_introspection_cpp.so /opt/ros/foxy/lib/libbuiltin_interfaces__rosidl_typesupport_cpp.so /opt/ros/foxy/lib/libbuiltin_interfaces__rosidl_generator_c.so /opt/ros/foxy/lib/librosidl_typesupport_introspection_cpp.so /opt/ros/foxy/lib/librosidl_typesupport_introspection_c.so /opt/ros/foxy/lib/librosidl_typesupport_cpp.so /opt/ros/foxy/lib/librosidl_typesupport_c.so /opt/ros/foxy/lib/librosidl_runtime_c.so /opt/ros/foxy/lib/librcpputils.so /opt/ros/foxy/lib/librcutils.so -ldl
make[2]: Leaving directory '/home/mainuser/colcon_ws/build/dynamixel_sdk_custom_interfaces'
[ 12%] Built target dynamixel_sdk_custom_interfaces__rosidl_generator_c
make[1]: Leaving directory '/home/mainuser/colcon_ws/build/dynamixel_sdk_custom_interfaces'
make: *** [Makefile:149: all] Error 2
--- stderr: dynamixel_sdk_custom_interfaces
make[1]: *** No rule to make target 'dynamixel_sdk_custom_interfaces__py/CMakeFiles/dynamixel_sdk_custom_interfaces__py.dir/all', needed by 'CMakeFiles/dynamixel_sdk_custom_interfaces__python.dir/all'. Stop.
make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:149: all] Error 2
---
Failed <<< dynamixel_sdk_custom_interfaces [1.42s, exited with code 2]
Summary: 0 packages finished [1.63s]
1 package failed: dynamixel_sdk_custom_interfaces
1 package had stderr output: dynamixel_sdk_custom_interfaces
This used to work for me as I mentioned above. I attempted to debug my ros2 packages in visual code and might have altered some settings (I don't remember editing system settings though, just settings in visual code) but either way, it was working, but now isn't and I can't think of anything that caused it or a way to solve it. Any help would be appreciated. The only solution I see now is reinstalling the operating system which I would prefer not to at this point.

cmake find_package for libxml2 doesn't return valid header directories

I'm on ubuntu and I've installed gcc, cmake, libxml2-dev and I've this CMakeLists.txt file:
cmake_minimum_required(VERSION 2.8)
find_package(LIBXML2 CONFIG)
include_directories(${LIBXML2_INCLUDE_DIRS})
link_libraries(${LIBXML2_LIBRARY})
add_executable(testusage testusage.cpp)
I run "cmake ." OK, and then make VERBOSE=1 it gives compilation error:
Scanning dependencies of target testusage
[ 50%] Building CXX object CMakeFiles/testusage.dir/testusage.cpp.o
/home/a/proj/mynet/mytest/cpp3p/useXml2/testusage.cpp:1:9: fatal error: libxml/parser.h: no such file or directory
#include<libxml/parser.h>
^~~~~~~~~~~~~~~~~
compilation terminated.
CMakeFiles/testusage.dir/build.make:62: recipe for target 'CMakeFiles/testusage.dir/testusage.cpp.o' failed
make[2]: *** [CMakeFiles/testusage.dir/testusage.cpp.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/testusage.dir/all' failed
make[1]: *** [CMakeFiles/testusage.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
Seems that "include_directories" didn't add any "-I" option into Makefile. How could I fix it?
Works fine for me, as soon as I use find_package(LibXml2) instead of find_package(LIBXML2 CONFIG). According to cmake-documentation, the config-mode tries to find a configuration-file, provided by the package:
Config mode search attempts to locate a configuration file provided by
the package to be found. A cache entry called _DIR is
created to hold the directory containing the file. By default the
command searches for a package with the name . If the
NAMES option is given the names following it are used instead of
. The command searches for a file called
Config.cmake or -config.cmake
for each name specified. A replacement set of possible configuration
file names may be given using the CONFIGS option.
So it seems to me, as if libxml2 does not provide such a config-file.
testusage.cpp
#include <iostream>
#include <libxml/parser.h>
int main(void)
{
xmlParserNodeInfo info;
std::cout << std::hex << &info << std::endl;
}
CMakeLists.txt
cmake_minimum_required(VERSION 2.8)
find_package(LibXml2)
include_directories(${LIBXML2_INCLUDE_DIRS})
link_libraries(${LIBXML2_LIBRARY})
add_executable(testusage testusage.cpp)
calling and building it
$ cmake .
-- The C compiler identification is GNU 7.3.0
-- The CXX compiler identification is GNU 7.3.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
-- Detecting C compile features
-- Detecting C compile features - done
-- 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
-- Found LibXml2: /usr/lib/x86_64-linux-gnu/libxml2.so (found version "2.9.4")
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/test/build
$ make --trace
Makefile:176: target 'cmake_check_build_system' does not exist
/usr/bin/cmake -H/tmp/test -B/tmp/test/build --check-build-system CMakeFiles/Makefile.cmake 0
Makefile:83: update target 'all' due to: cmake_check_build_system
/usr/bin/cmake -E cmake_progress_start /tmp/test/build/CMakeFiles /tmp/test/build/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
CMakeFiles/Makefile2:67: target 'CMakeFiles/testusage.dir/all' does not exist
make -f CMakeFiles/testusage.dir/build.make CMakeFiles/testusage.dir/depend
CMakeFiles/testusage.dir/build.make:112: target 'CMakeFiles/testusage.dir/depend' does not exist
cd /tmp/test/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /tmp/test /tmp/test /tmp/test/build /tmp/test/build /tmp/test/build/CMakeFiles/testusage.dir/DependInfo.cmake --color=
Scanning dependencies of target testusage
make -f CMakeFiles/testusage.dir/build.make CMakeFiles/testusage.dir/build
CMakeFiles/testusage.dir/build.make:62: update target 'CMakeFiles/testusage.dir/testusage.cpp.o' due to: ../testusage.cpp /usr/include/libxml2/libxml/SAX.h /usr/include/libxml2/libxml/SAX2.h /usr/include/libxml2/libxml/dict.h /usr/include/libxml2/libxml/encoding.h /usr/include/libxml2/libxml/entities.h /usr/include/libxml2/libxml/globals.h /usr/include/libxml2/libxml/hash.h /usr/include/libxml2/libxml/list.h /usr/include/libxml2/libxml/parser.h /usr/include/libxml2/libxml/threads.h /usr/include/libxml2/libxml/tree.h /usr/include/libxml2/libxml/valid.h /usr/include/libxml2/libxml/xlink.h /usr/include/libxml2/libxml/xmlIO.h /usr/include/libxml2/libxml/xmlautomata.h /usr/include/libxml2/libxml/xmlerror.h /usr/include/libxml2/libxml/xmlexports.h /usr/include/libxml2/libxml/xmlmemory.h /usr/include/libxml2/libxml/xmlregexp.h /usr/include/libxml2/libxml/xmlstring.h /usr/include/libxml2/libxml/xmlversion.h CMakeFiles/testusage.dir/flags.make
/usr/bin/cmake -E cmake_echo_color --switch= --green --progress-dir=/tmp/test/build/CMakeFiles --progress-num=1 "Building CXX object CMakeFiles/testusage.dir/testusage.cpp.o"
[ 50%] Building CXX object CMakeFiles/testusage.dir/testusage.cpp.o
/usr/bin/c++ -I/usr/include/libxml2 -o CMakeFiles/testusage.dir/testusage.cpp.o -c /tmp/test/testusage.cpp
CMakeFiles/testusage.dir/build.make:95: update target 'testusage' due to: CMakeFiles/testusage.dir/link.txt CMakeFiles/testusage.dir/testusage.cpp.o CMakeFiles/testusage.dir/build.make /usr/lib/x86_64-linux-gnu/libxml2.so
/usr/bin/cmake -E cmake_echo_color --switch= --green --bold --progress-dir=/tmp/test/build/CMakeFiles --progress-num=2 "Linking CXX executable testusage"
[100%] Linking CXX executable testusage
/usr/bin/cmake -E cmake_link_script CMakeFiles/testusage.dir/link.txt --verbose=
/usr/bin/cmake -E cmake_echo_color --switch= --progress-dir=/tmp/test/build/CMakeFiles --progress-num=1,2 "Built target testusage"
[100%] Built target testusage
/usr/bin/cmake -E cmake_progress_start /tmp/test/build/CMakeFiles 0
$ ./testusage
0x7ffe0c7a5360

W10 + Clion, set up error

I am trying to set up Clion on my pc. I tried both Clion and mingw and I get the same error when I point to the tool chain location. I install and uninstall all the required packages for both following the instructions and I can't get it working.
Anyone else has run into this set up issue?
This is the error I am getting:
Error:The C++ compiler "/usr/bin/c++.exe" is not able to compile a simple test program.
It fails with the following output:
Change Dir: /cygdrive/c/Users/satin/.CLion2016.2/system/cmake/generated/untitled-9502414e/9502414e/__default__/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make.exe" "cmTC_4ce80/fast"
/usr/bin/make -f CMakeFiles/cmTC_4ce80.dir/build.make CMakeFiles/cmTC_4ce80.dir/build
make[1]: Entering directory '/cygdrive/c/Users/satin/.CLion2016.2/system/cmake/generated/untitled-9502414e/9502414e/__default__/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_4ce80.dir/testCXXCompiler.cxx.o
/usr/bin/c++.exe -o CMakeFiles/cmTC_4ce80.dir/testCXXCompiler.cxx.o -c /cygdrive/c/Users/satin/.CLion2016.2/system/cmake/generated/untitled-9502414e/9502414e/__default__/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
Linking CXX executable cmTC_4ce80.exe
/cygdrive/c/Users/satin/.CLion2016.2/system/cygwin_cmake/bin/cmake.exe -E cmake_link_script CMakeFiles/cmTC_4ce80.dir/link.txt --verbose=1
/usr/bin/c++.exe -Wl,--enable-auto-import CMakeFiles/cmTC_4ce80.dir/testCXXCompiler.cxx.o -o cmTC_4ce80.exe -Wl,--out-implib,libcmTC_4ce80.dll.a -Wl,--major-image-version,0,--minor-image-version,0
c++: fatal error: -fuse-linker-plugin, but cyglto_plugin.dll not found
compilation terminated.
make[1]: *** [CMakeFiles/cmTC_4ce80.dir/build.make:98: cmTC_4ce80.exe] Error 1
make[1]: Leaving directory '/cygdrive/c/Users/satin/.CLion2016.2/system/cmake/generated/untitled-9502414e/9502414e/__default__/CMakeFiles/CMakeTmp'
make: *** [Makefile:126: cmTC_4ce80/fast] Error 2
CMake will not be able to correctly generate this project.
Error:Configuration Debug
The C++ compiler "/usr/bin/c++.exe" is not able to compile a simple test program.
It fails with the following output:
Change Dir: /cygdrive/c/Users/satin/.CLion2016.2/system/cmake/generated/untitled-9502414e/9502414e/Debug/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make.exe" "cmTC_4526e/fast"
/usr/bin/make -f CMakeFiles/cmTC_4526e.dir/build.make CMakeFiles/cmTC_4526e.dir/build
make[1]: Entering directory '/cygdrive/c/Users/satin/.CLion2016.2/system/cmake/generated/untitled-9502414e/9502414e/Debug/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_4526e.dir/testCXXCompiler.cxx.o
/usr/bin/c++.exe -o CMakeFiles/cmTC_4526e.dir/testCXXCompiler.cxx.o -c /cygdrive/c/Users/satin/.CLion2016.2/system/cmake/generated/untitled-9502414e/9502414e/Debug/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
Linking CXX executable cmTC_4526e.exe
/cygdrive/c/Users/satin/.CLion2016.2/system/cygwin_cmake/bin/cmake.exe -E cmake_link_script CMakeFiles/cmTC_4526e.dir/link.txt --verbose=1
/usr/bin/c++.exe -Wl,--enable-auto-import CMakeFiles/cmTC_4526e.dir/testCXXCompiler.cxx.o -o cmTC_4526e.exe -Wl,--out-implib,libcmTC_4526e.dll.a -Wl,--major-image-version,0,--minor-image-version,0
c++: fatal error: -fuse-linker-plugin, but cyglto_plugin.dll not found
compilation terminated.
make[1]: *** [CMakeFiles/cmTC_4526e.dir/build.make:98: cmTC_4526e.exe] Error 1
make[1]: Leaving directory '/cygdrive/c/Users/satin/.CLion2016.2/system/cmake/generated/untitled-9502414e/9502414e/Debug/CMakeFiles/CMakeTmp'
make: *** [Makefile:126: cmTC_4526e/fast] Error 2
CMake will not be able to correctly generate this project.
Error:Configuration Release
The C++ compiler "/usr/bin/c++.exe" is not able to compile a simple test program.
It fails with the following output:
Change Dir: /cygdrive/c/Users/satin/.CLion2016.2/system/cmake/generated/untitled-9502414e/9502414e/Release/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make.exe" "cmTC_0c461/fast"
/usr/bin/make -f CMakeFiles/cmTC_0c461.dir/build.make CMakeFiles/cmTC_0c461.dir/build
make[1]: Entering directory '/cygdrive/c/Users/satin/.CLion2016.2/system/cmake/generated/untitled-9502414e/9502414e/Release/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_0c461.dir/testCXXCompiler.cxx.o
/usr/bin/c++.exe -o CMakeFiles/cmTC_0c461.dir/testCXXCompiler.cxx.o -c /cygdrive/c/Users/satin/.CLion2016.2/system/cmake/generated/untitled-9502414e/9502414e/Release/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
Linking CXX executable cmTC_0c461.exe
/cygdrive/c/Users/satin/.CLion2016.2/system/cygwin_cmake/bin/cmake.exe -E cmake_link_script CMakeFiles/cmTC_0c461.dir/link.txt --verbose=1
/usr/bin/c++.exe -Wl,--enable-auto-import CMakeFiles/cmTC_0c461.dir/testCXXCompiler.cxx.o -o cmTC_0c461.exe -Wl,--out-implib,libcmTC_0c461.dll.a -Wl,--major-image-version,0,--minor-image-version,0
c++: fatal error: -fuse-linker-plugin, but cyglto_plugin.dll not found
compilation terminated.
make[1]: *** [CMakeFiles/cmTC_0c461.dir/build.make:98: cmTC_0c461.exe] Error 1
make[1]: Leaving directory '/cygdrive/c/Users/satin/.CLion2016.2/system/cmake/generated/untitled-9502414e/9502414e/Release/CMakeFiles/CMakeTmp'
make: *** [Makefile:126: cmTC_0c461/fast] Error 2
CMake will not be able to correctly generate this project.
Error:Configuration RelWithDebInfo
The C++ compiler "/usr/bin/c++.exe" is not able to compile a simple test program.
It fails with the following output:
Change Dir: /cygdrive/c/Users/satin/.CLion2016.2/system/cmake/generated/untitled-9502414e/9502414e/RelWithDebInfo/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make.exe" "cmTC_0238e/fast"
/usr/bin/make -f CMakeFiles/cmTC_0238e.dir/build.make CMakeFiles/cmTC_0238e.dir/build
make[1]: Entering directory '/cygdrive/c/Users/satin/.CLion2016.2/system/cmake/generated/untitled-9502414e/9502414e/RelWithDebInfo/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_0238e.dir/testCXXCompiler.cxx.o
/usr/bin/c++.exe -o CMakeFiles/cmTC_0238e.dir/testCXXCompiler.cxx.o -c /cygdrive/c/Users/satin/.CLion2016.2/system/cmake/generated/untitled-9502414e/9502414e/RelWithDebInfo/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
Linking CXX executable cmTC_0238e.exe
/cygdrive/c/Users/satin/.CLion2016.2/system/cygwin_cmake/bin/cmake.exe -E cmake_link_script CMakeFiles/cmTC_0238e.dir/link.txt --verbose=1
/usr/bin/c++.exe -Wl,--enable-auto-import CMakeFiles/cmTC_0238e.dir/testCXXCompiler.cxx.o -o cmTC_0238e.exe -Wl,--out-implib,libcmTC_0238e.dll.a -Wl,--major-image-version,0,--minor-image-version,0
c++: fatal error: -fuse-linker-plugin, but cyglto_plugin.dll not found
compilation terminated.
make[1]: *** [CMakeFiles/cmTC_0238e.dir/build.make:98: cmTC_0238e.exe] Error 1
make[1]: Leaving directory '/cygdrive/c/Users/satin/.CLion2016.2/system/cmake/generated/untitled-9502414e/9502414e/RelWithDebInfo/CMakeFiles/CMakeTmp'
make: *** [Makefile:126: cmTC_0238e/fast] Error 2
CMake will not be able to correctly generate this project.
Error:Configuration MinSizeRel
The C++ compiler "/usr/bin/c++.exe" is not able to compile a simple test program.
It fails with the following output:
Change Dir: /cygdrive/c/Users/satin/.CLion2016.2/system/cmake/generated/untitled-9502414e/9502414e/MinSizeRel/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make.exe" "cmTC_7f6fc/fast"
/usr/bin/make -f CMakeFiles/cmTC_7f6fc.dir/build.make CMakeFiles/cmTC_7f6fc.dir/build
make[1]: Entering directory '/cygdrive/c/Users/satin/.CLion2016.2/system/cmake/generated/untitled-9502414e/9502414e/MinSizeRel/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_7f6fc.dir/testCXXCompiler.cxx.o
/usr/bin/c++.exe -o CMakeFiles/cmTC_7f6fc.dir/testCXXCompiler.cxx.o -c /cygdrive/c/Users/satin/.CLion2016.2/system/cmake/generated/untitled-9502414e/9502414e/MinSizeRel/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
Linking CXX executable cmTC_7f6fc.exe
/cygdrive/c/Users/satin/.CLion2016.2/system/cygwin_cmake/bin/cmake.exe -E cmake_link_script CMakeFiles/cmTC_7f6fc.dir/link.txt --verbose=1
/usr/bin/c++.exe -Wl,--enable-auto-import CMakeFiles/cmTC_7f6fc.dir/testCXXCompiler.cxx.o -o cmTC_7f6fc.exe -Wl,--out-implib,libcmTC_7f6fc.dll.a -Wl,--major-image-version,0,--minor-image-version,0
c++: fatal error: -fuse-linker-plugin, but cyglto_plugin.dll not found
compilation terminated.
make[1]: *** [CMakeFiles/cmTC_7f6fc.dir/build.make:98: cmTC_7f6fc.exe] Error 1
make[1]: Leaving directory '/cygdrive/c/Users/satin/.CLion2016.2/system/cmake/generated/untitled-9502414e/9502414e/MinSizeRel/CMakeFiles/CMakeTmp'
make: *** [Makefile:126: cmTC_7f6fc/fast] Error 2
CMake will not be able to correctly generate this project.
Cygwin's C++ compiler (or probably linker) can't find cyglto_plugin.dll which can be part of several Cygwin packages. I'm not sure how Clion works - whether it requires Cygwin to be installed or brings it in its own installer. If it requires that user installs Cygwin - verify that you have installed appropriate package and that mentioned DLL is in place.
I removed all the packages and reinstalled them. I think when you have the options to download it allows you to download multiple versions. Which is what i did and then it causes a conflict. issue was resolved.

CMAKE Error /usr/bin/cc -- broken

I am trying to compile a simple .cpp file but when i issue cmake .. its throw error
-- The C compiler identification is GNU 4.7.3
-- The CXX compiler identification is GNU 4.7.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/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: /home/user/jagdish/hello/CMakeFiles/CMakeTmp
Run Build Command:/usr/bin/make "cmTryCompileExec3772316685/fast"
/usr/bin/make -f CMakeFiles/cmTryCompileExec3772316685.dir/build.make
CMakeFiles/cmTryCompileExec3772316685.dir/build
make[1]: Entering directory `/home/user/jagdish/hello/CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report
/home/user/jagdish/hello/CMakeFiles/CMakeTmp/CMakeFiles 1
Building C object
CMakeFiles/cmTryCompileExec3772316685.dir/testCCompiler.c.o
/usr/bin/cc -o CMakeFiles/cmTryCompileExec3772316685.dir/testCCompiler.c.o
-c /home/user/jagdish/hello/CMakeFiles/CMakeTmp/testCCompiler.c
Linking C executable cmTryCompileExec3772316685
/usr/bin/cmake -E cmake_link_script
CMakeFiles/cmTryCompileExec3772316685.dir/link.txt --verbose=1
/usr/bin/cc CMakeFiles/cmTryCompileExec3772316685.dir/testCCompiler.c.o -o
cmTryCompileExec3772316685 -rdynamic
collect2: error: ld terminated with signal 11 [Segmentation fault]
make[1]: *** [cmTryCompileExec3772316685] Error 1
make[1]: Leaving directory `/home/user/jagdish/hello/CMakeFiles/CMakeTmp'
make: *** [cmTryCompileExec3772316685/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
-- Configuring incomplete, errors occurred!
See also "/home/user/jagdish/hello/CMakeFiles/CMakeOutput.log".
See also "/home/user/jagdish/hello/CMakeFiles/CMakeError.log".

CMake to Makefile - Makefile gives `collect2: error: ld returned 1 exit status`

I am trying to familiarize my self with Cmake by following this example:
In short I have this c++ code . I want to generate a makefile for this code using Cmake and then run the makefile. Unfortunately the Makefile generated gives out an error. I am using Windows 7
Here is the code that I am using
File: main.cpp
#include "ToDo.h"
int main( int argc, char** argv)
{
ToDo list;
return 0;
}
File: ToDo.h
#ifndef TODO_H
#define TODO_H
class ToDo
{
public:
ToDo();
~ToDo();
};
File:ToDo.cpp
#include "ToDo.h"
ToDo::ToDo()
{
}
ToDo::~ToDo()
{
}
#endif // TODO_H
This my CMakeLists.txt
project("To Do List")
add_executable(toDo main.cpp ToDo.cpp)
Here is what I am doing in cygwin
admin#US01WKS03044 /cygdrive/c/CmakeTest/build
$ cmake -G "Unix Makefiles" ..
-- The C compiler identification is unknown
-- The CXX compiler identification is GNU 4.9.2
-- Check for working C compiler: C:/cygwin64/bin/cc
-- Check for working C compiler: C:/cygwin64/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working CXX compiler: C:/cygwin64/bin/c++.exe
-- Check for working CXX compiler: C:/cygwin64/bin/c++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Detecting CXX compile features
-- Detecting CXX compile features - failed
-- Configuring done
-- Generating done
-- Build files have been written to: C:/CmakeTest/build
admin#US01WKS03044 /cygdrive/c/CmakeTest/build
$ ls
cmake_install.cmake CMakeCache.txt CMakeFiles Makefile
admin#US01WKS03044 /cygdrive/c/CmakeTest/build
$ make VERBOSE=1
"C:/Program Files (x86)/CMake/bin/cmake.exe" -HC:/CmakeTest -BC:/CmakeTest/build --check-build-system CMakeFiles/Makefile.cmake 0
"C:/Program Files (x86)/CMake/bin/cmake.exe" -E cmake_progress_start C:/CmakeTest/build/CMakeFiles C:/CmakeTest/build/CMakeFiles/progress.marks
/usr/bin/make -f CMakeFiles/Makefile2 all
make[1]: Entering directory `/cygdrive/c/CmakeTest/build'
/usr/bin/make -f CMakeFiles/toDo.dir/build.make CMakeFiles/toDo.dir/depend
make[2]: Entering directory `/cygdrive/c/CmakeTest/build'
"C:/Program Files (x86)/CMake/bin/cmake.exe" -E cmake_depends "Unix Makefiles" C:/CmakeTest C:/CmakeTest C:/CmakeTest/build C:/CmakeTest/build C:/CmakeTest/build/CMakeFiles/toDo.dir/DependInfo.cmake --color=
Dependee "C:/CmakeTest/build/CMakeFiles/toDo.dir/DependInfo.cmake" is newer than depender "C:/CmakeTest/build/CMakeFiles/toDo.dir/depend.internal".
Dependee "C:/CmakeTest/build/CMakeFiles/CMakeDirectoryInformation.cmake" is newer than depender "C:/CmakeTest/build/CMakeFiles/toDo.dir/depend.internal".
Scanning dependencies of target toDo
make[2]: Leaving directory `/cygdrive/c/CmakeTest/build'
/usr/bin/make -f CMakeFiles/toDo.dir/build.make CMakeFiles/toDo.dir/build
make[2]: Entering directory `/cygdrive/c/CmakeTest/build'
"C:/Program Files (x86)/CMake/bin/cmake.exe" -E cmake_progress_report C:/CmakeTest/build/CMakeFiles 1
[ 50%] Building CXX object CMakeFiles/toDo.dir/main.cpp.o
C:/cygwin64/bin/c++.exe -o CMakeFiles/toDo.dir/main.cpp.o -c C:/CmakeTest/main.cpp
"C:/Program Files (x86)/CMake/bin/cmake.exe" -E cmake_progress_report C:/CmakeTest/build/CMakeFiles 2
[100%] Building CXX object CMakeFiles/toDo.dir/ToDo.cpp.o
C:/cygwin64/bin/c++.exe -o CMakeFiles/toDo.dir/ToDo.cpp.o -c C:/CmakeTest/ToDo.cpp
Linking CXX executable toDo.exe
"C:/Program Files (x86)/CMake/bin/cmake.exe" -E remove -f CMakeFiles/toDo.dir/objects.a
C:/cygwin64/bin/ar.exe cr CMakeFiles/toDo.dir/objects.a #CMakeFiles/toDo.dir/objects1.rsp
C:/cygwin64/bin/c++.exe -Wl,--whole-archive CMakeFiles/toDo.dir/objects.a -Wl,--no-whole-archive -o toDo.exe -Wl,--out-implib,libtoDo.dll.a -Wl,--major-image-version,0,--minor-image-version,0
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../lib/libcygwin.a(libcmain.o): In function `main':
/usr/src/debug/cygwin-1.7.33-1/winsup/cygwin/lib/libcmain.c:39: undefined reference to `WinMain'
/usr/src/debug/cygwin-1.7.33-1/winsup/cygwin/lib/libcmain.c:39:(.text.startup+0x7e): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `WinMain'
collect2: error: ld returned 1 exit status
make[2]: *** [toDo.exe] Error 1
make[2]: Leaving directory `/cygdrive/c/CmakeTest/build'
make[1]: *** [CMakeFiles/toDo.dir/all] Error 2
make[1]: Leaving directory `/cygdrive/c/CmakeTest/build'
make: *** [all] Error 2
Why did the Makefile fail ?
The error means that the compiler is looking for WinMain as the entrypoint of your executable, instead of the classic main, and it can't find it.
As I don't use cygwin, can't really say why that is (WinMain is specific to windows gui apps, if I'm not mistaking), but you could to rename main to WinMain and see if it works. Or see http://log4aj.blogspot.ro/2010/11/cygwin-gcc-undefined-reference-to.html.