My ultimate goal is to run CACTUS. It requires CMake, so I have downloaded both. I think CMake needs a compiler, so I downloaded MinGW (or gfortran or GNU, I'm not really sure the distinction).
Using the MinGW Installation Manager, I've installed mingw32-base, mingw32-gcc-fortran, and also all the MinGW libraries because at one point I thought it would help. I have navigated through
control panel>system>advanced system settings>advanced>environment
variables and in user variables I have added the variables CMake and FC with the values C:\ProgramFiles\CMake\bin and C:\MinGW\bin, respectively.
I also edited the path in system variables to include both of those as well as C:\MinGW\mingw32\bin. I've also downloaded and installed Microsoft Visual Studio 2019 because I read somewhere that it was necessary for gfortran to work, though I have not done anything directly with it so far. At this point, I open Windows command prompt (this is all in Windows 10), navigate to the build folder that I have created in the top CACTUS folder and type
cmake ../
It returns this:
-- Could NOT find BLAS (missing: BLAS_LIBRARIES)
-- LAPACK requires BLAS
-- A library with LAPACK API not found. Please specify library location.
-- Could NOT find OpenMP_Fortran (missing: OpenMP_Fortran_FLAGS OpenMP_Fortran_LIB_NAMES)
CMake Warning (dev) at C:/Program Files/CMake/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:272 (message):
The package name passed to `find_package_handle_standard_args` (OpenMP)
does not match the name of the calling package (OPENMP). This can lead to
problems in calling code that expects `find_package` result variables
(e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.17/Modules/FindOpenMP.cmake:579 (find_package_handle_standard_args)
CMakeLists.txt:30 (find_package)
This warning is for project developers. Use -Wno-dev to suppress it.
-- Could NOT find OpenMP (missing: OpenMP_Fortran_FOUND)
CMake Error at CMakeLists.txt:32 (message):
OPENMP option was set to true (default), but no OpenMP was found. Install
OpenMP, or try again with -DOPENMP=OFF. Exiting.
-- Configuring incomplete, errors occurred!
Starting at the top of that error, I did some googling and found these instructions starting at "Build Instructions to create LAPACK and LAPACKE 3.5.0 dlls for Windows with MinGW". I followed those instructions for Win32. After running C:/MinGW/bin/mingw32-make.exe from command prompt, it gets to 36% and errs with the following message:
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: cannot find -lFALSE
collect2.exe: error: ld returned 1 exit status
SRC\CMakeFiles\lapack.dir\build.make:28574: recipe for target 'bin/liblapack.dll' failed
mingw32-make.exe[2]: *** [bin/liblapack.dll] Error 1
CMakeFiles\Makefile2:2077: recipe for target 'SRC/CMakeFiles/lapack.dir/all' failed
mingw32-make.exe[1]: *** [SRC/CMakeFiles/lapack.dir/all] Error 2
Makefile:181: recipe for target 'all' failed
mingw32-make.exe: *** [all] Error 2
I have also tried directions here and here and have either had no luck or, frankly, don't understand them. I am not a programmer. I have lived a life spoiled by GUIs and single install programs with everything included. I don't know what to try anymore. I don't really understand what's wrong or, honestly, why I've taken most of the steps I've taken except that someone in another help forum suggested them. I guarantee that I will have follow up questions to your answers, but please help.
EDIT
As requested below, here is the config file for lapack after cmake:
# Load the LAPACK package with which we were built.
set(LAPACK_DIR "C:/Users/x/Downloads/lapack/lapack-3.9.0/build")
find_package(LAPACK NO_MODULE)
# Load lapack targets from the build tree, including lapacke targets.
if(NOT TARGET lapacke)
include("C:/Users/x/Downloads/lapack/lapack-3.9.0/build/lapack-targets.cmake")
endif()
# Hint for project building against lapack
set(LAPACKE_Fortran_COMPILER_ID ${LAPACK_Fortran_COMPILER_ID})
# Report lapacke header search locations from build tree.
set(LAPACKE_INCLUDE_DIRS "C:/Users/x/Downloads/lapack/lapack-3.9.0/build/include")
# Report lapacke libraries.
set(LAPACKE_LIBRARIES lapacke ${LAPACK_LIBRARIES})
And, yes, I did choose to build the LAPACKE Library in CMake.
Related
I want to run MinGW as a C compiler. MinGW has been installed from Chocolatey. Invocation is from gitlab-runner through CMake. This fails with
$ cmake -G "MinGW Makefiles" -DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc -DLIB_MAN=OFF -DCMAKE_INSTALL_PREFIX=C:\opt\x64 -B. ..
-- The C compiler identification is unknown
-- Check for working C compiler: C:/ProgramData/chocolatey/bin/x86_64-w64-mingw32-gcc.exe
-- Check for working C compiler: C:/ProgramData/chocolatey/bin/x86_64-w64-mingw32-gcc.exe -- broken
CMake Error at C:/Program Files/CMake/share/cmake-3.16/Modules/CMakeTestCCompiler.cmake:60 (message):
The C compiler
"C:/ProgramData/chocolatey/bin/x86_64-w64-mingw32-gcc.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/gitlab-runner/builds/zjE1Mkfg/0/mlz/kww/build/CMakeFiles/CMakeTmp
Run Build Command(s):C:/ProgramData/chocolatey/bin/mingw32-make.exe cmTC_ffa53/fast && C:/ProgramData/chocolatey/lib/mingw/tools/install/mingw64/bin/mingw32-make -f CMakeFiles\cmTC_ffa53.dir\build.make CMakeFiles/cmTC_ffa53.dir/build
mingw32-make[1]: Entering directory 'C:/gitlab-runner/builds/zjE1Mkfg/0/mlz/kww/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_ffa53.dir/testCCompiler.c.obj
C:\ProgramData\chocolatey\bin\x86_64-w64-mingw32-gcc.exe -o CMakeFiles\cmTC_ffa53.dir\testCCompiler.c.obj -c C:\gitlab-runner\builds\zjE1Mkfg\0\mlz\kww\build\CMakeFiles\CMakeTmp\testCCompiler.c
mingw32-make[1]: *** [CMakeFiles\cmTC_ffa53.dir\build.make:65: CMakeFiles/cmTC_ffa53.dir/testCCompiler.c.obj] Error 1
mingw32-make[1]: Leaving directory 'C:/gitlab-runner/builds/zjE1Mkfg/0/mlz/kww/build/CMakeFiles/CMakeTmp'
mingw32-make: *** [Makefile:120: cmTC_ffa53/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:/gitlab-runner/builds/zjE1Mkfg/0/mlz/kww/build/CMakeFiles/CMakeOutput.log".
See also "C:/gitlab-runner/builds/zjE1Mkfg/0/mlz/kww/build/CMakeFiles/CMakeError.log".
ERROR: Job failed: exit status 1
From various web sources I understand that MinGW is bound to fail if sh.exe is present on the system [1]. However, sh.exe comes with several applications, among them Git and Visual Studio, which I cannot remove. Somewhere it's suggested to add -DCMAKE_SH="CMAKE_SH-NOTFOUND", which, however, has no effect.
I've seen a related question from 2015 [2], which however involves CLion. The only upvoted answer contains several broken links - altogether, that thread isn't helpful.
How to proceed? Is there a chance to work around the sh.exe problem?
Other advice on the web suggests to use -G "MSYS Makefiles". However, the CMake documentation [3] seems to rule this out: "not compatible with a Windows command prompt. To build under a Windows command prompt, use the MinGW Makefiles generator."
[1] https://stackoverflow.com/a/7411982/1017348
[2] CLion: Error:The C compiler "C:/MinGW/bin/gcc.exe" is not able to compile a simple test program
[3] https://cmake.org/cmake/help/latest/generator/MSYS%20Makefiles.html#generator:MSYS%20Makefiles per CMake 3.16.1
After long experimentation, I conclude that the problem comes from Chocolatey's packaging of MinGW. The problem is gone after I
uninstalled the MinGW package from Chocolatey,
reinstalled MinGW using the original MinGW installer,
installed the Ninja Chocolatey package,
inserted C:\MinGW\bin on top of PATH.
$ cmake -G "Ninja" -DLIB_MAN=OFF -DCMAKE_INSTALL_PREFIX=C:\opt\x64 -B. ..
-- The C compiler identification is GNU 8.2.0
-- Check for working C compiler: C:/MinGW/bin/gcc.exe
-- Check for working C compiler: C:/MinGW/bin/gcc.exe -- works
Also note:
There is no need for -DCMAKE_C_COMPILER=...
I did not try hard to get -G "MinGW Makefile" working; -G Ninja works just fine.
The sh.exe is only a problem when you run CMake the first time when trying to generate the project. You can rerun CMake again and CMake will continue with normal processing to generate the project (tested in version 3.16). I saw a patch that removes this check and should be part of a future release of CMake.
It's already mentioned that gcc is installed incorrectly. That always seems to be the case when anyone mentions that gcc fails with an Error 1 message. It should be noted that Error 1 is not from CMake. CMake is just gathering the output from when it runs mingw32-make to build the sample project.
The first message in the output -- The C compiler identification is unknown is a pretty clear message that your compiler isn't working. All of the output for this step is in the log and error files that CMake generates in the build folder. You'll be able to see how it invoked the compiler and with which options and the output from the compiler.
I'm new on this IDE, and programming on Windows, I've installed MinGW and added to enviroment path all is ok, I can compile and execute code from "cmd", but when I run CLion I have this error:
-- 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 2017.3.1/bin/cmake/share/cmake-3.9/Modules/CMakeTestCCompiler.cmake:51 (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/noName/AppData/Local/Temp/cmake_check_environment/_build/CMakeFiles/CMakeTmp
Run Build Command:"C:/MinGW/bin/mingw32-make.exe" "cmTC_2e43b/fast"
C:/MinGW/bin/mingw32-make.exe -f CMakeFiles\cmTC_2e43b.dir\build.make
CMakeFiles/cmTC_2e43b.dir/build
mingw32-make.exe1: Entering directory
'C:/Users/noName/AppData/Local/Temp/cmake_check_environment/_build/CMakeFiles/CMakeTmp'
CMakeFiles\cmTC_2e43b.dir\build.make:64: recipe for target
'CMakeFiles/cmTC_2e43b.dir/testCCompiler.c.obj' failed
process_begin:
CreateProcess(C:\Users\noName\AppData\Local\Temp\make2428-1.bat,
C:\Users\noName\AppData\Local\Temp\make2428-1.bat, ...) failed.
make (e=2): El sistema no puede encontrar el archivo especificado.
mingw32-make.exe1: *** [CMakeFiles/cmTC_2e43b.dir/testCCompiler.c.obj]
Error 2
mingw32-make.exe1: Leaving directory
'C:/Users/noName/AppData/Local/Temp/cmake_check_environment/_build/CMakeFiles/CMakeTmp'
Makefile:125: recipe for target 'cmTC_2e43b/fast' failed
mingw32-make.exe: *** [cmTC_2e43b/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/noName/AppData/Local/Temp/cmake_check_environment/_build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/noName/AppData/Local/Temp/cmake_check_environment/_build/CMakeFiles/CMakeError.log".
Error code: 1
This is the photo. I think this is and error with CMake(?)
your windows 64bit and you can't write gcc.exe and g++.exe in windows 64 . you should try installing mingw-w64.
you can download this From here and installing this.
after that you should go in CLion setting -> build,Execution,deployment -> Toolchains
and configuration like this picture
and for installer mingw-w64 you should installer default option.
I encountered the same problem with mingw-32. Here is my solution.
First I removed all packages through MinGW Installer. Then as Jetbrains quick tutorial suggests I went to this page to download MingW-W64-builds. Installed it as x86_64. Under Toolchain | Environment clicked ... after the first dropdown slot, specified the folder called mingw64 under my installation. MinGW version should be "w64 5.0". This time no error report and Make, C compiler and C++ compiler were detected.
open the MinGW Installation Manger,and choose all the items under the path of All packages/MinGW/MinGW Base System to installation.
I keep going back to this question every now and then when I encounter the same error, although the cause of it in my cases is not present in any of the previous answers. In general, MinGW package (or CMake, whichever it is) does not like it when either it or file(s) we want it to work with is placed in a path with non-latin characters. Changing the directory of the project and / or MinGW installation solves the issue every time.
I'm trying to use Qt Creator for C++ CMake project which doesn't use the Qt libraries.
I'm following the official guide, but it does not work at all. Here are my steps:
Add my MinGW bin directory to PATH.
Run QtCreator and setup CMake.
Open a a very basic CMakeLists.txt file.
Select "Ninja (Desktop)" as CMake generator.
Getting errors from CMake.
You may have noticed that step 4 is actually not mentioned at all in the official guide. I'm quite used to CMake and as such I'm asking myself:
Why doesn't the Qt Creator offer the normal "MinGW Makefiles" generator?
And finally the ultimate question:
How can I make the Qt Creator use a MinGW compiler through CMake?
Answered questions:
According to the official guide and as usual when you set PATH correctly, step 5 should not happen.
Why doesn't CMake find the compiler set in PATH?
It's the Ninja Generator that creates these errors, the same thing happens if you do it manually with CMake.
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_CXX_COMPILER_ENV_VAR
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_CXX_COMPILER
CMake Error: Could not find cmake module file: D:/Programming/C++/Test/SupportQt/build/CMakeFiles/3.0.2/CMakeCXXCompiler.cmake
CMake Error at CMakeLists.txt:1 (project):
No CMAKE_C_COMPILER could be found.
Tell CMake where to find the compiler by setting 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 at CMakeLists.txt:1 (project):
No CMAKE_CXX_COMPILER could be found.
Tell CMake where to find the compiler by setting the CMake cache entry
CMAKE_CXX_COMPILER to the full path to the compiler, or to the compiler
name if it is in the PATH.
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_C_COMPILER_ENV_VAR
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_C_COMPILER
CMake Error: Could not find cmake module file: D:/Programming/C++/Test/SupportQt/build/CMakeFiles/3.0.2/CMakeCCompiler.cmake
CMake Error: CMake was unable to find a build program corresponding to "Ninja". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.-- Configuring incomplete, errors occurred!
Looking at the configuration menu to see whether I have forgotten to setup something, I stumbled across the compiler setup page. I then of course added my compiler there as well, but it did nothing.
Why doesn't CMake use the compiler list when using CMake?
It does use the compiler list, IF you pick the right compiler in the kits selection.
As usually if you ask for help only to shortly after figure it out, I feel quite stupid now...
Why doesn't the Qt Creator use the compiler list when using CMake?
It does, but only if you set the Kit to use the right compiler!
Why doesn't CMake find the compiler set in PATH?
This is actually the problem of the Ninja Generator with CMake. The same thing happens if you use CMake directly.
Why doesn't the Qt Creator offer the normal "MinGW Makefiles" generator?
It does, but only if you picked a MinGW compiler in your Kit!
How can I make the Qt Creator use a MinGW compiler through CMake?
By setting everything up correctly and not relying too heavily on the official guide.
I am trying to build boost. I followed the instructions here. I create a folder C:\Boost which contains include and libs and I add it to my enviroment path. However, when I tried to build another project with cMake I am getting:
CMake Error at C:/Program Files/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:1106 (message):
Unable to find the requested Boost libraries.
Boost version: 1.55.0
Boost include path: C:/Boost/include/boost-1_55
The following Boost libraries could not be found:
boost_system
boost_filesystem
boost_signals
No Boost libraries were found. You may need to set BOOST_LIBRARYDIR to the
directory containing Boost libraries or BOOST_ROOT to the location of
Boost.
Call Stack (most recent call first):
CMakeLists.txt:88 (find_package)
Any idea about those missing libs?
It's a bad thing to start an answer with a question, but I do it nevertheless:
First, am I right in assuming that you've set an environment variable BOOST_ROOT pointing to C:\Boost? (Simply adding it to the path might not be sufficient here.)
Second, which CMake generator are you running? Visual Studio, Makefile, ninja?
I've head a similar problem recently that was connected to the generator that I was actually using. More precisely, I was trying to create a Ninja project from within cmake-gui and got almost the same error message. However, I was able to create a Visual Studio project in cmake-gui project without problem.
When looking a little closer at the command output for the Ninja case I found the following two lines at the very beginning:
The C compiler identification is unknown
The CXX compiler identification is unknown
This hints at the actual problem. While it is clear which compiler will be in use for Visual Studio (9, 10, 11, ...), cmake cannot infer a default compiler for Ninja because it is a generic build system that runs with different compilers. In the end boost wasn't found because the compiler is unknown.
A simple solution was to open the Developer Command Prompt for the Visual Studio version that you want to run with. When you create the project in this "extended" command prompt CMake will be able to infer the correct compiler. Alternatively, you can set the CMAKE_CXX_COMPILER and CMAKE_C_COMPILER flags when running cmake.
cmake -G "Ninja" <path/to/CMakeLists.txt>
cmake -G "Ninja" <path/to/CMakeLists.txt> -DCMAKE_CXX_COMPILER="path/to/cxx/compiler" -CMAKE_C_COMPILER="path/to/c/compiler"
I am trying to build the boost::locale library (http://cppcms.sourceforge.net/boost_locale/html/tutorial.html#a5771bce93e200c36f7cd9dfd0e5deaa) which is still in review for integration into boost but the cmake command throws up the following:
D:\lib\boost_locale_v2.92\build>cmake ..
-- Looking for ICU libraries
-- Looking for iconv
-- Looking for Boost
CMake Error: The following variables are used in this project, but they are se
to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake fi
s:
BOOST_THREAD
linked by target "boost_locale-static" in directory D:/lib/boost_locale_v2
2
ICU_DATA
linked by target "boost_locale-static" in directory D:/lib/boost_locale_v2
2
ICU_I18N
linked by target "boost_locale-static" in directory D:/lib/boost_locale_v2
2
ICU_INCLUDE_DIR
used as include directory in directory D:/lib/boost_locale_v2.92
ICU_UC
linked by target "boost_locale-static" in directory D:/lib/boost_locale_v2
2
-- Configuring incomplete, errors occurred!
I have got ICU and boost but can't figure out how to modify the out-of-box cmake script for boost::locale. Any help is appreciated
Actually these error messages are clear enough. You need to point where is what: boost thread library location, ICU include directory, and others.
Read the installation instructions carefully:
http://cppcms.sourceforge.net/boost_locale/html/building_boost_locale.html
You need to provide:
cmake -DCMAKE_INCLUDE_PATH=/path/to/boost/include;path/to/icu/include -DCMAKE_LIBRARY_PATH=/path/to/icu/lib ..