Cmake refuses to find the correct MinGW folder - c++

I'm completely at a loss here.
I have a C++ project that uses CMake. It used to work, but recently some weird problems came up, so I decided to reinstall the Qt SDK and CMake. However, now I get the following error when trying to build a file:
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:61 (message):
The C compiler "C:/Qt/Qt5.0.1/Tools/MinGW/bin/gcc.exe" is not able to
compile a simple test program.
It fails with the following output:
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:1 (project)
CMake Error: your C compiler: "C:/Qt/Qt5.0.1/Tools/MinGW/bin/gcc.exe" was not found. Please set CMAKE_C_COMPILER to a valid compiler path or name.
CMake Error: your CXX compiler: "C:/Qt/Qt5.0.1/Tools/MinGW/bin/g++.exe" was not found. Please set CMAKE_CXX_COMPILER to a valid compiler path or name.
CMake Error: Internal CMake error, TryCompile configure of cmake failed
CMake Error: your C compiler: "C:/Qt/Qt5.0.1/Tools/MinGW/bin/gcc.exe" was not found. Please set CMAKE_C_COMPILER to a valid compiler path or name.-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- Check for working C compiler: C:/Qt/Qt5.0.1/Tools/MinGW/bin/gcc.exe
-- Check for working C compiler: C:/Qt/Qt5.0.1/Tools/MinGW/bin/gcc.exe -- broken
-- Configuring incomplete, errors occurred!
This completely boggles my mind. MinGW is located in C:/Qt/Qt5.0.2/Tools/, not Qt5.0.1. I tell it so in the CMakeLists.txt file:
SET(CMAKE_C_COMPILER C:/Qt/Qt5.0.2/Tools/MinGW/bin/gcc)
SET(CMAKE_CXX_COMPILER C:/Qt/Qt5.0.2/Tools/MinGW/bing++)
I even added C:/Qt/Qt5.0.2/Tools/MinGW/bin/ to the global PATH variable, but this hasn't helped any. CMake keeps thinking it should be in Qt5.0.1 -- a folder that doesn't exist.
Does anybody know what option I might be overlooking? I've tried just about everything.

I also had the "not able to compile a simple test program"-issue (Qt Creator, CMake). The reason in my case was that the path to CMake contained forbidden characters: neither spaces nor parentheses are apparently allowed. Uninstalling CMake and reinstalling it under \ProgramFilesx86\CMake fixed the issue for me.

I have problem same as you and I found the answer for this. It seem be like mingw of Qt has bug so you will get the error like "gcc is broken". Reinstall mingw at http://www.mingw.org/ and link gcc.exe, g++.exe from C:\MingW\Bin\ to your CMake. Build it again and see.
Good luck!

Related

Error :The CMAKE_CXX_COMPILER: D:/Qt/bin/clang/bin/clang.exe is not a full path to an existing compiler tool

The general messages on running QT creator to build my code says
*Running Windows Runtime device detection.
No winrtrunner.exe found.
Running Windows Runtime device detection.
No winrtrunner.exe found.
Running Windows Runtime device detection.
No winrtrunner.exe found.
Running "C:\Program Files\CMake\bin\cmake.exe -E server "--pipe=\\.\pipe\{8cd95c25-ccf7-4bd3-92e3-6efb4a56f1b5}" --experimental" in D:\build-tudatBundle-Desktop-Release.
Starting to parse CMake project.
The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:21 (project):
The CMAKE_CXX_COMPILER:
D:/Qt/bin/clang/bin/clang.exe
is not a full path to an existing compiler tool.
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.
Configuring incomplete, errors occurred!
See also "D:/build-tudatBundle-Desktop-Release/CMakeFiles/CMakeOutput.log".
See also "D:/build-tudatBundle-Desktop-Release/CMakeFiles/CMakeError.log".
CMake Deprecation Warning:
The 'cmake-server(7)' is deprecated. Please port clients to use the
'cmake-file-api(7)' instead.
CMake Project parsing failed.*
What is wintrunner?
Where do I amend the path as that path doesn't exist. I've configured on QT creator to the right compiler path but it uses this particular path - 'D:/Qt/bin/clang/bin/clang.exe'
Any other sources of error?
Please edit this question to make it suitable for reading. I'm unaware of the format, but I'd appreciate any and all help. Let me know if you need more information.

Android linphone building under Ubuntu 16.04 giving error of cmake path variable of CC and CXX?

I am trying to build linphone on linux Ubuntu 16.04 32 bit system. I have downloaded all the required libraries and install cmake. But i always ended with error as shown below.
cmake /home/silvans/linphone_new/linphone-android/submodules/cmake-builder -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_PREFIX_PATH=/home/silvans/linphone_new/linphone-android/liblinphone-sdk/android-arm64 -DCMAKE_INSTALL_PREFIX=/home/silvans/linphone_new/linphone-android/liblinphone-sdk/android-arm64 -DCMAKE_NO_SYSTEM_FROM_IMPORTED=YES -DLINPHONE_BUILDER_WORK_DIR=/home/silvans/linphone_new/linphone-android/WORK/android-arm64 -DCMAKE_TOOLCHAIN_FILE=toolchains/toolchain-android-arm64.cmake -DCMAKE_INSTALL_MESSAGE=LAZY -DLINPHONE_BUILDER_CONFIG_FILE=configs/config-android.cmake -DLINPHONE_BUILDER_EXTERNAL_SOURCE_PATH=/home/silvans/linphone_new/linphone-android/submodules
-- Android: Selected Clang toolchain 'aarch64-linux-android-clang3.6' with GCC toolchain 'aarch64-linux-android-4.9'
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error in CMakeLists.txt:
The CMAKE_C_COMPILER:
/home/silvans/Downloads/android-ndk-r11c/toolchains/llvm/prebuilt/linux-x86/bin/clang
is not a full path to an existing compiler tool.
Tell CMake where to find the compiler by setting either the environment
variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
the compiler, or to the compiler name if it is in the PATH.
CMake Error in CMakeLists.txt:
The CMAKE_CXX_COMPILER:
/home/silvans/Downloads/android-ndk-r11c/toolchains/llvm/prebuilt/linux-x86/bin/clang++
is not a full path to an existing compiler tool.
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.
-- Configuring incomplete, errors occurred!
See also "/home/silvans/linphone_new/linphone-android/WORK/android-
arm64/cmake/CMakeFiles/CMakeOutput.log".
See also "/home/silvans/linphone_new/linphone-android/WORK/android-arm64/cmake/CMakeFiles/CMakeError.log".
As per error shown set the path for CC and CXX as below,
export CC=/usr/bin/gcc
export PATH=$PATH:$CC
export CXX=/usr/bin/g++
export PATH=$PATH:$CXX
But still i am getting the same error message. Please let me know what is wrong in the path variable of C and C++ compilers. How can i set them in the system so that cmake can find the path of both compilers.
Thanks,
Your compiler is not able to locate proper toolchain.
exporting it to /usr/bin/gcc is not correct solution, because i.e. gcc compiler for your native machine and if I'm right here you trying to cross compile.
Follow the link given below:
https://github.com/android-ndk/ndk/issues/111
Linphone wiki:
https://linphone.org/dokuwiki/doku.php/getting-started:android
See if it is helpful.

Building cpp-netlib with CMake

I've downloaded the cpp-netlib source, extracted it to a folder and for some reason I'm completely lost. I read the documentation carefully, it states I have to download CMake as well, which I did. Then I set the source directory and build directories, and upon clicking the "Generate" button I got this output:
The CXX compiler identification is MSVC 19.0.23506.0
Check for working C compiler using: Visual Studio 14 2015
Check for working C compiler using: Visual Studio 14 2015 -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Check for working CXX compiler using: Visual Studio 14 2015
Check for working CXX compiler using: Visual Studio 14 2015 -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Detecting CXX compile features
Detecting CXX compile features - done
CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.5/Modules/FindBoost.cmake:1657 (message):
Unable to find the requested Boost libraries.
Unable to find the Boost header files. Please set BOOST_ROOT to the root
directory containing Boost or BOOST_INCLUDEDIR to the directory containing
Boost's headers.
Call Stack (most recent call first):
CMakeLists.txt:49 (find_package)
Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR (missing: OPENSSL_LIBRARIES OPENSSL_INCLUDE_DIR)
Looking for pthread.h
Looking for pthread.h - not found
Found Threads: TRUE
CMake Error at CMakeLists.txt:131 (export):
export given target "cppnetlib-client-connections" which is not built by
this project.
Configuring incomplete, errors occurred!
See also "C:/Users/Nick/Documents/cpp-netlib/cpp-netlib-build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/Nick/Documents/cpp-netlib/cpp-netlib-build/CMakeFiles/CMakeError.log"
It couldn't find the Boost libraries, and that's where I'm stuck. I installed boost, but I have no idea where to set "BOOST_ROOT". I did some research on that, tried to use the command line with the -DBOOST_ROOT option like so:
c:\Program Files>cmake -DBOOST_ROOT=/boost/boost_1_55_0
But it gives me the following error:
CMake Error: The source directory "C:/Program Files" does not appear to contain
CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.
I'm really unsure as to what to do now and I feel this isn't the end of my problems... Is there anything obvious I'm missing?
You need to either run cmake from the source tree (which would contain CMakeLists.txt), or, more typically, run it from a build folder and tell it where the source tree is.
A common case would be creating a build folder next to the source tree and running cmake ../sourcedir.
You seem to have initially been using a gui; surely that provides a means to set the BOOST_ROOT variable?
Alternatively, if you just put boost in the VC++ include/lib paths (either in the vc dirs, or by setting %INCLUDE%/%LIB%), you probably would not need BOOST_ROOT. Same for OpenSSL.

Compile OpenSceneGraph with Cmake under Windows

I am trying to set up Openscenegraph 3.0.1 with Cmake. I read different blog posts but it doesn't work.
I set up the paths, click compile and selected VS11 (because I have VS 2012) and use native compiler.
Then I directly get this error:
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules CMakeCInformation.cmake:37 (get_filename_component):
get_filename_component called with incorrect number of arguments
Call Stack (most recent call first):
CMakeLists.txt:3 (PROJECT)
CMake Error: Internal CMake error, TryCompile configure of cmake failed
Looking for include file pthread.h - not found
Also, more errors with the same stack trace occur. Also also could paste them here if you wish.
Afterwards, CMake tells me "Error in configuration process, project files may be invalid"
your problem isn't in compiler version that you are using; in fact, i'm running OpenSceneGraph 3(and osgEarth) with no problems on VisualStudio 2012.
What it seems to be is a problem with Cmake/CMakeLists.txt itself. Try to build some other projects using cmake, to see whether they work, or try to use a version of CMake that is close to what OpenSceneGraph needs(look at CMAKE_MINIMUM_REQUIRED in main CMakeLists.txt file), although CMake language is meant to be compatible with earlier versions, i dont know if this is always the case.
pthread.h has nothing to do with your problem, DOESN'T EXIST in Windows(except if you are using MinGW to look for some more problems), and is not required by OSG - i think, you configured OpenThreads correctly to not use libs you don't have. Anyway, that's just part of the job CMake does on each build - looks for some random stuff, like whether it can find pthreads.h or not, that give CMake some idea about your environment and don't usually relate to the projects you build with cmake. So just ignore that line about pthread.h
Under normal circumstances, CMake shouldn't be looking for pthread for Windows. Following is the couple of lines in CMake's (2.8) FindThreads.cmake which is used for searching appropriate modules.
...
CHECK_INCLUDE_FILES("pthread.h" CMAKE_HAVE_PTHREAD_H)
if(CMAKE_HAVE_PTHREAD_H)
...
endif()
...
if(CMAKE_SYSTEM MATCHES "Windows")
set(CMAKE_USE_WIN32_THREADS_INIT 1)
set(Threads_FOUND TRUE)
endif()
As you can see, first check should fail and roll out till the second check. However, I believe that in your case, CMake somehow finds that pthread.h (maybe you have MinGW as well) This seems to be a simple conflict in your system. Check your system's PATH etc. and try to fix it.

CMake error when configuring itkvtkglue

My question is similar to Emre's question. I am trying to build the itkImageToVTKImageFilter example from the wiki. I hope to use it for a Gaussian low pass filter that I plan to apply to an image. After I download the itkvtkglue, extract it to a folder, and then press configure in Cmake, I receive the following error message:
Check for working C compiler using: Visual Studio 9 2008
Check for working C compiler using: Visual Studio 9 2008 -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Check for working CXX compiler using: Visual Studio 9 2008
Check for working CXX compiler using: Visual Studio 9 2008 -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
CMake Error at F:/ITK/ItkVtkGlue/bin/UseItkVtkGlue.cmake:10 (include):
include could not find load file:
G:/VTK/UseVTK.cmake
Call Stack (most recent call first):
CMakeLists.txt:13 (include)
Configuring incomplete, errors occurred!
I was not sure what could be causing the error but I suspected that it had something to do with my Windows system path. However, it also seems to be pointing to the correct folder (PATH goes to F: drive). The error indicates that Cmake is looking within G: drive for some unknown reason.
Here is the CMakeLists.txt for itkImageToVTKImageFilter:
cmake_minimum_required(VERSION 2.8)
project(DiscreteGaussianImageFilter)
find_package(ITK REQUIRED)
include(${ITK_USE_FILE})
if (ITKVtkGlue_LOADED)
find_package(VTK REQUIRED)
include(${VTK_USE_FILE})
else()
find_package(ItkVtkGlue REQUIRED)
include(${ItkVtkGlue_USE_FILE})
set(Glue ItkVtkGlue)
endif()
add_executable(DiscreteGaussianImageFilter MACOSX_BUNDLE DiscreteGaussianImageFilter.cxx)
target_link_libraries(DiscreteGaussianImageFilter
${Glue} ${VTK_LIBRARIES} ${ITK_LIBRARIES})
I read that this was a very common problem but I am unsure how to correct it. Any help would be greatly appreciated! I am still very new to Stackoverflow so let me know if I need to provide more info.
Works now. I needed to rebuild ITK with ITK_BUILD_ALL_MODULES on as well as checking the Module_ITKVtkGlue which I didn't do before.