CMAKE Error /usr/bin/cc -- broken - c++

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".

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.

CLion - can't run a program on apple m1

I ran clion a month ago and it worked perfectly. Now when I run a program I get:
/bin/sh: /Users/a/Library/Application Support/JetBrains/Toolbox/apps/CLion-ARM/ch-0/203.7717.62/CLion.app/Contents/bin/cmake/mac/bin/cmake: No such file or directory
make: *** [cmake_check_build_system] Error 127
Also, on clion startup, the cmake tool window shows me an error:
CMake Warning at /Users/a/Library/Application Support/JetBrains/Toolbox/apps/CLion/ch-1/211.7142.21/CLion.app/Contents/bin/cmake/mac/share/cmake-3.19/Modules/Platform/Darwin-Initialize.cmake:303 (message):
Ignoring CMAKE_OSX_SYSROOT value:
/Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk
because the directory does not exist.
Call Stack (most recent call first):
/Users/a/Library/Application Support/JetBrains/Toolbox/apps/CLion/ch-1/211.7142.21/CLion.app/Contents/bin/cmake/mac/share/cmake-3.19/Modules/CMakeSystemSpecificInitialize.cmake:21 (include)
CMakeLists.txt:2 (project)
-- The C compiler identification is AppleClang 12.0.5.12050022
-- The CXX compiler identification is AppleClang 12.0.5.12050022
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - broken
CMake Error at /Users/a/Library/Application Support/JetBrains/Toolbox/apps/CLion/ch-1/211.7142.21/CLion.app/Contents/bin/cmake/mac/share/cmake-3.19/Modules/CMakeTestCCompiler.cmake:66 (message):
The C compiler
"/Library/Developer/CommandLineTools/usr/bin/cc"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /Users/a/CLionProjects/untitled1/cmake-build-debug/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/make cmTC_e3f61/fast && /Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/cmTC_e3f61.dir/build.make CMakeFiles/cmTC_e3f61.dir/build
Building C object CMakeFiles/cmTC_e3f61.dir/testCCompiler.c.o
/Library/Developer/CommandLineTools/usr/bin/cc -arch arm64 -o CMakeFiles/cmTC_e3f61.dir/testCCompiler.c.o -c /Users/a/CLionProjects/untitled1/cmake-build-debug/CMakeFiles/CMakeTmp/testCCompiler.c
Linking C executable cmTC_e3f61
"/Users/a/Library/Application Support/JetBrains/Toolbox/apps/CLion/ch-1/211.7142.21/CLion.app/Contents/bin/cmake/mac/bin/cmake" -E cmake_link_script CMakeFiles/cmTC_e3f61.dir/link.txt --verbose=1
/Library/Developer/CommandLineTools/usr/bin/cc -arch arm64 -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/cmTC_e3f61.dir/testCCompiler.c.o -o cmTC_e3f61
ld: library not found for -lSystem
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [cmTC_e3f61] Error 1
make: *** [cmTC_e3f61/fast] Error 2
I have xcode command line tools installed. What should I do?
Erase cmake-build-... directory manually and reload a CMake project.

Test Cmake run finished with errors (CLION)

I have the following problem after changing path to one that is easier for the operating system. My MinGW configuration in CLion:
-- 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 2018.2.5/bin/cmake/win/share/cmake-3.12/Modules/CMakeTestCCompiler.cmake:52 (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/Michał/AppData/Local/Temp/cmake_check_environment/_build/CMakeFiles/CMakeTmp
Run Build Command:"C:/MinGW/bin/mingw32-make.exe" "cmTC_da460/fast"
C:/MinGW/bin/mingw32-make.exe -f CMakeFiles\cmTC_da460.dir\build.make CMakeFiles/cmTC_da460.dir/build
mingw32-make.exe[1]: Entering directory 'C:/Users/Micha│/AppData/Local/Temp/cmake_check_environment/_build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_da460.dir/testCCompiler.c.obj
C:\MinGW\bin\gcc.exe -o CMakeFiles\cmTC_da460.dir\testCCompiler.c.obj -c C:\Users\Michał\AppData\Local\Temp\cmake_check_environment\_build\CMakeFiles\CMakeTmp\testCCompiler.c
gcc.exe: error: C:\Users\Michał\AppData\Local\Temp\cmake_check_environment\_build\CMakeFiles\CMakeTmp\testCCompiler.c: No such file or directory
gcc.exe: fatal error: no input files
compilation terminated.
CMakeFiles\cmTC_da460.dir\build.make:64: recipe for target 'CMakeFiles/cmTC_da460.dir/testCCompiler.c.obj' failed
mingw32-make.exe[1]: *** [CMakeFiles/cmTC_da460.dir/testCCompiler.c.obj] Error 1
mingw32-make.exe[1]: Leaving directory 'C:/Users/Micha│/AppData/Local/Temp/cmake_check_environment/_build/CMakeFiles/CMakeTmp'
Makefile:120: recipe for target 'cmTC_da460/fast' failed
mingw32-make.exe: *** [cmTC_da460/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/Michał/AppData/Local/Temp/cmake_check_environment/_build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/Michał/AppData/Local/Temp/cmake_check_environment/_build/CMakeFiles/CMakeError.log".
Error code: 1
Here is a screenshot from my PC:

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.

Linking error of BLAS with CMake

I have the following CMakeLists.txt:
cmake_minimum_required (VERSION 2.6)
project (MTSOS)
# Select flags.
set(CMAKE_C_FLAGS "-std=c99")
# Blas library
find_package( BLAS REQUIRED )
include_directories(${BLAS_INCLUDE_DIR})
add_executable (test_MTSOS test_MTSOS.c barrier_front.c dynamics_front.c
MTSOS.c csparse.c)
# Linking CImg dependencies.
target_link_libraries (test_MTSOS m blas ${BLAS_LIBRARIES})
When I run cmake .. :
-- The C compiler identification is GNU 4.8.2
-- The CXX compiler identification is GNU 4.8.2
-- 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/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Looking for dgemm_
-- Looking for dgemm_ - found
-- Looking for include file pthread.h
-- Looking for include file pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- A library with BLAS API found.
-- Configuring done
-- Generating done
-- Build files have been written to: /home/jabuntu14/Desktop/MTSOS/build
However, when I try to compile with make:
Scanning dependencies of target test_MTSOS
[ 20%] Building C object CMakeFiles/test_MTSOS.dir/test_MTSOS.c.o
[ 40%] Building C object CMakeFiles/test_MTSOS.dir/barrier_front.c.o
/home/jabuntu14/Desktop/MTSOS/barrier_front.c: In function ‘so_barrier’:
/home/jabuntu14/Desktop/MTSOS/barrier_front.c:83:25: warning: implicit declaration of function ‘dsyr’ [-Wimplicit-function-declaration]
dsyr(uplo, &u_size, &alpha, &Df[i*U_size], &one, A, &u_size);
^
[ 60%] Building C object CMakeFiles/test_MTSOS.dir/dynamics_front.c.o
[ 80%] Building C object CMakeFiles/test_MTSOS.dir/MTSOS.c.o
/home/jabuntu14/Desktop/MTSOS/MTSOS.c: In function ‘so_MakeA’:
/home/jabuntu14/Desktop/MTSOS/MTSOS.c:1561:13: warning: implicit declaration of function ‘dgemv’ [-Wimplicit-function-declaration]
dgemv(chn, &m_m, &n_m, &one, &M_dynamics[i*State_size*State_size], &m_m, &S_prime[i*State_size], &p_m, &zero, datam, &p_m);
^
[100%] Building C object CMakeFiles/test_MTSOS.dir/csparse.c.o
Linking C executable test_MTSOS
CMakeFiles/test_MTSOS.dir/barrier_front.c.o: In function `so_barrier':
barrier_front.c:(.text+0x4a7): undefined reference to `dsyr'
CMakeFiles/test_MTSOS.dir/MTSOS.c.o: In function `so_MakeA':
MTSOS.c:(.text+0x5e41): undefined reference to `dgemv'
MTSOS.c:(.text+0x5ee4): undefined reference to `dgemv'
MTSOS.c:(.text+0x5f87): undefined reference to `dgemv'
collect2: error: ld returned 1 exit status
make[2]: *** [test_MTSOS] Error 1
make[1]: *** [CMakeFiles/test_MTSOS.dir/all] Error 2
make: *** [all] Error 2
So I am having a linking problem but I cannot figure out why. Any help is welcome. Thanks!!
NOTE: Working under Ubuntu 14.04 with GCC. In the .c files I have included #include "cblas.h" as I saw in other websites.
EDIT: running make VERBOSE=1 the output is:
jabuntu14#ubuntu:~/Desktop/MTSOS/build$ make VERBOSE=1
/usr/bin/cmake -H/home/jabuntu14/Desktop/MTSOS -B/home/jabuntu14/Desktop/MTSOS/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/jabuntu14/Desktop/MTSOS/build/CMakeFiles /home/jabuntu14/Desktop/MTSOS/build/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory `/home/jabuntu14/Desktop/MTSOS/build'
make -f CMakeFiles/test_MTSOS.dir/build.make CMakeFiles/test_MTSOS.dir/depend
make[2]: Entering directory `/home/jabuntu14/Desktop/MTSOS/build'
cd /home/jabuntu14/Desktop/MTSOS/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/jabuntu14/Desktop/MTSOS /home/jabuntu14/Desktop/MTSOS /home/jabuntu14/Desktop/MTSOS/build /home/jabuntu14/Desktop/MTSOS/build /home/jabuntu14/Desktop/MTSOS/build/CMakeFiles/test_MTSOS.dir/DependInfo.cmake --color=
make[2]: Leaving directory `/home/jabuntu14/Desktop/MTSOS/build'
make -f CMakeFiles/test_MTSOS.dir/build.make CMakeFiles/test_MTSOS.dir/build
make[2]: Entering directory `/home/jabuntu14/Desktop/MTSOS/build'
Linking C executable test_MTSOS
/usr/bin/cmake -E cmake_link_script CMakeFiles/test_MTSOS.dir/link.txt --verbose=1
/usr/bin/cc -std=c99 CMakeFiles/test_MTSOS.dir/test_MTSOS.c.o CMakeFiles/test_MTSOS.dir/barrier_front.c.o CMakeFiles/test_MTSOS.dir/dynamics_front.c.o CMakeFiles/test_MTSOS.dir/MTSOS.c.o CMakeFiles/test_MTSOS.dir/csparse.c.o -o test_MTSOS -rdynamic -lm -lblas -lf77blas -latlas
CMakeFiles/test_MTSOS.dir/barrier_front.c.o: In function `so_barrier':
barrier_front.c:(.text+0x4a7): undefined reference to `dsyr'
CMakeFiles/test_MTSOS.dir/MTSOS.c.o: In function `so_MakeA':
MTSOS.c:(.text+0x5e41): undefined reference to `dgemv'
MTSOS.c:(.text+0x5ee4): undefined reference to `dgemv'
MTSOS.c:(.text+0x5f87): undefined reference to `dgemv'
collect2: error: ld returned 1 exit status
make[2]: *** [test_MTSOS] Error 1
make[2]: Leaving directory `/home/jabuntu14/Desktop/MTSOS/build'
make[1]: *** [CMakeFiles/test_MTSOS.dir/all] Error 2
make[1]: Leaving directory `/home/jabuntu14/Desktop/MTSOS/build'
make: *** [all] Error 2
The functions in standard blas libraries are
dgemv_
Instead of
dgemv
As shown in your error, notice the trailing underscore.
So you probably have something in your code calling dgemv() instead of dgemv_(), change that and then you should be fine.
(I had the same issue where the code I was using had some like #define dgemv_ dgemv)