No CMAKE_Fortran_COMPILER could be found - c++

I am using CMake for my c++ and Fortran projects. I use the Intel Fortran compiler and VS2017. Every time I try to configure the project in the CMake-gui I get this error:
The Fortran compiler identification is unknown
CMake Error at Lib/Fast_Table/CMakeLists.txt:2 (project):
No CMAKE_Fortran_COMPILER could be found.
I have looked all over the internet for the solution and I can't seem to find any solution for my problem. The Paths all seem correct and match other peers with the same project.
Here are the errors that show up in the CMakeError.log file:
Compiling the Fortran compiler identification source file "CMakeFortranCompilerId.F" failed.
Package 'IFLangServicePackage' failed to load.
LINK : fatal error LNK1104: cannot open file 'ifconsol.lib'
The .F file in the error above compiles on it's own and so do other VS2017 Fortran projects I have tried to build in VS2017. It's the configuration and generation process in the cmake-gui that is giving these errors.

My installations of VS2017 and Intel Fortran were not setting up correctly. I had to go to the Intel Fortran solution in my build directory under .\CMakeFiles\3.18.4\CompilerIdFortran. I opened the project in Visual Studio. Tools >> Options >> Intel Compilers and Tools >> Visual Fortran >> Compilers. Then I went to the x64 tab and instead of having "Latest" selected, I selected "Intel(R) Visual Fortran Compiler 19.1.0.166 [Intel(R) 64]" and this had the proper setup for compiling Fortran. There were also some files in the 2020 compilers_and_libraries dir that were not in the 2020.0.166 dir.

Related

Error: No CMAKE_Fortran_COMPILER could be found for Visual Studio 2019 Fortran support

I am using CMAKE to build Open Source Projects (like those are available at GitHub etc.) and I also have installed Visual Studio 2019. There is a problem that CMAKE can not find Fortran compiler in my system whereas I've installed MinGW with Fortran compiler. The error is:
**The Fortran compiler identification is unknown**
**No CMAKE_Fortran_COMPILER could be found.**
How can I solve this problem and make CMAKE be aware of Fortran compiler?
Note: I tried other projects that does not require Fortran compiler and those are built successfully.
Installed software:
CMAKE 3.18.5,
Visual Studio 2019,
MinGW
You need to show where your fortran executable file to CMakeList.txt like
set(CMAKE_Fortran_COMPILER "C:/MinGW/bin/gfortran.exe")
EDIT 2 for Visual studio 2019:
If you want to produce Visual Studio 2019 solution
Download IntelĀ® oneAPI HPC Toolkit here.
If cmake cannot find Fortran compiler add a cmake flag CMAKE_Fortran_COMPILER with the value of ifort.exe path that u installed above. Like %install_path%/Intel/oneAPI/compiler/2021.1.1/windows/bin/intel64/ifort.exe
Configure and generate solution.
EDIT:
Alright, now I understand why you get this error. The Visual Studio generator does not support MinGW gfortran. They are totally separate ecosystems.
Remove your build directory and create a fresh one. Then use cmake .. -G "MinGW Makefiles" instead. I tried from CLI prompt of msys and successfully obtained the libraries from Windows machine.
If you are using Intel processors, you should first set-up Fortran environment for Visual Studio 2019
Better to check compilation guide and some troubleshooting Fortran Integration Issues with visual studio

LLVM build fails on Visual Studio

I generated a Visual Studio 15 2017 project with CMake to compile LLVM and Clang myself. I've tried to build the ALL_BUILD project from Visual Studio (as the getting started page suggested).
But the build failed with a linking error due to (I assume) the linker did not have permission to open a file. This specific file was LLVM-C.def.
The error message:
Cannot Open File '<path_to_build_folder>/build/tools/llvm-shlib/LLVM-C.def
I've tried to give full permission to the user, also tried as admin but did not work.
edit:
The file did not get created because the gen-msvc-exports.py script fails to locate a libllvm-c.args file. It searches the Debug directory for this file but I found it in the $(Configuration) directory. Could this be some Visual Studio configuration/macro problem?
edit2:
Also is there any workaround to get the Clang Tooling library to work on Windows? The precompiled package doesn't contain any headers or static libraries to work with (but for some reason the Linux one does).

CXX and C Compiler identification is unknown [duplicate]

We are having trouble compiling a project using CMake (v2.8.12) under Windows 7 64Bit using Visual Studio 2012. CMake gives us the following errors. We already tried starting Cmake from the Visual Studio Command Line using admin rights. There seems to have been a similar bug in CMake 2.8.11: http://www.cmake.org/Bug/view.php?id=14440
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeDetermineCompilerId.cmake:446 (execute_process):
execute_process given COMMAND argument with no value.
Call Stack (most recent call first):
C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeDetermineCompilerId.cmake:48 (CMAKE_DETERMINE_COMPILER_ID_VENDOR)
C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeDetermineCCompiler.cmake:131 (CMAKE_DETERMINE_COMPILER_ID)
CMakeLists.txt:2 (project)
The C compiler identification is unknown
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeDetermineCompilerId.cmake:446 (execute_process):
execute_process given COMMAND argument with no value.
Call Stack (most recent call first):
C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeDetermineCompilerId.cmake:48 (CMAKE_DETERMINE_COMPILER_ID_VENDOR)
C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeDetermineCXXCompiler.cmake:127 (CMAKE_DETERMINE_COMPILER_ID)
CMakeLists.txt:2 (project)
The CXX compiler identification is unknown
Could NOT find SWIG (missing: SWIG_EXECUTABLE SWIG_DIR)
CMake Warning at src/CMakeLists.txt:44 (message):
SWIG was not found. You will not be able to compile for C#.
Configuring incomplete, errors occurred!
See also "C:/Users/hci/laser_control/CMakeFiles/CMakeOutput.log".
See also "C:/Users/hci/laser_control/CMakeFiles/CMakeError.log".
I had the same issue and fixed it running cmake as Admin
Those error messages
The C compiler identification is unknown
The CXX compiler identification is unknown
means CMake did find or assume a compiler but it wasn't able to compile a simple test program.
Take a look at CMakeFiles\CMakeError.log and check the error message there to see:
which compiler path/command line CMake did use
what the error message calling the compiler was
e.g. LINK : fatal error LNK1181: cannot open input file 'kernel32.lib'
If you add --debug-trycompile to the cmake call CMake will even keep the files it has tried to test compile (so you can copy/paste/re-run the command line from the error log in your cmd shell).
The last time I had this problem ...
The last time I had this problem was when my Visual Studio 2012 Professional standard installation did not install any Windows SDK (the error log was showing an missing SDK header).
To verify your SDK installation e.g. check that you have any Resource Compiler installed. It should be in a path similar to:
C:\Program Files (x86)\Microsoft SDKs\Windows\v[some version]\bin\RC.Exe
Since I was missing this - or more accurate any SDK - I installed Windows 8.1 SDK (since Visual Studio 2012 does target Windows 8.x) and voila my CMake was able again to compile the (test) programs.
Reference
Does Visual Studio 2012 include the full Windows SDK
CMake Error at CMakeLists.txt:30 (project): No CMAKE_C_COMPILER could be found
I was getting the terminal output:
The C compiler identification is unknown
The CXX compiler identification is unknown
I checked the CMakeError.log output:
\build\CMakeFiles\CMakeError.log
It showed the error:
warning MSB8003: The WindowsSDKDir property is not defined. Some build tools may not be found.
Going back to visual Studio I needed to install the Windows 10 SDK:
After installing the SDK and running cmake it showed:
Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.18363.
The C compiler identification is MSVC 19.28.29334.0
The CXX compiler identification is MSVC 19.28.29334.0
And built successfully!
I had similar problem also, if you are using Microsoft Visual Studio 2012, that might be because of update of KB2781514 is missing.
After I installed following update, CMake start to detect Visual Studio 2012 c/c++ compilers correctly.
http://www.microsoft.com/en-us/download/details.aspx?id=36020
I faced the same problem. Building and running a project from Visual Studio didn't work for me. However following worked for me:
Open command prompt for developers from Visual Studio tools.
Goto the directory where cmake.exe is present.
Run it.
Lets hope it works for you as well.
For some reason, deleting the build folder in my machine, solved the issue.
cmake:
The cmake assume that you set g++ compiler path accurately.In case due any reason if it did't find compiler path{/usr/bin/g++} then it throw an error like:
**The CXX compiler identification is unknown**
So given step will short out this error:
Locate your compiler CXX path{for g++ path under Linux is :/usr/bin/g++}
Set the Compiler Path and export it configuration: PATH=/usr/bin:$PATH;export PATH
Export compiler like : export CXX=/usr/bin/g++-7
Here we assume that g++,cmake,build-essential install in your Linux system...!!
Same problem here with cmake 2.8.12 and visual studio 10. Cmake may not be able to find the compiler. I solved the problem by uninstalling latest version and installed cmake 2.8.10.
I just encounter with this issue, after I uninstalled some MS software.
I fixed it by repair visual studio 2012.
First go to [Control panel], then select visual studio and repair it,things will go right now.
Make sure you select the proper version of visual Studio.
For example, Visual Studio 2012 is version 11.
I had the same problem and I had to use the "File -> Delete Cache", since I accidentally configured CMake to use wrong visual studio version.
If you use CMake 3.4.0, try upgrading to a newer version. A bug concerning this was fixed relatively recently (see the bug report).
Make sure that you have installed Clang tools
open tools -> Get tools and features, select individual components, search cmake, then uninstall cmake and then re-install cmake, when complete, restart your computer.
I was seeing this on ubuntu - issue was cmake was assuming clang++ as c compiler.
CMake Error at /usr/share/cmake-3.10/Modules/CMakeTestCCompiler.cmake:52 (message):
The C compiler
"/usr/bin/clang++-9"
To fix it, export C, C++ compiler paths:
export CC=/usr/bin/clang
export CXX=/usr/bin/clang++

The CXX compiler identification is unknown

We are having trouble compiling a project using CMake (v2.8.12) under Windows 7 64Bit using Visual Studio 2012. CMake gives us the following errors. We already tried starting Cmake from the Visual Studio Command Line using admin rights. There seems to have been a similar bug in CMake 2.8.11: http://www.cmake.org/Bug/view.php?id=14440
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeDetermineCompilerId.cmake:446 (execute_process):
execute_process given COMMAND argument with no value.
Call Stack (most recent call first):
C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeDetermineCompilerId.cmake:48 (CMAKE_DETERMINE_COMPILER_ID_VENDOR)
C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeDetermineCCompiler.cmake:131 (CMAKE_DETERMINE_COMPILER_ID)
CMakeLists.txt:2 (project)
The C compiler identification is unknown
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeDetermineCompilerId.cmake:446 (execute_process):
execute_process given COMMAND argument with no value.
Call Stack (most recent call first):
C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeDetermineCompilerId.cmake:48 (CMAKE_DETERMINE_COMPILER_ID_VENDOR)
C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeDetermineCXXCompiler.cmake:127 (CMAKE_DETERMINE_COMPILER_ID)
CMakeLists.txt:2 (project)
The CXX compiler identification is unknown
Could NOT find SWIG (missing: SWIG_EXECUTABLE SWIG_DIR)
CMake Warning at src/CMakeLists.txt:44 (message):
SWIG was not found. You will not be able to compile for C#.
Configuring incomplete, errors occurred!
See also "C:/Users/hci/laser_control/CMakeFiles/CMakeOutput.log".
See also "C:/Users/hci/laser_control/CMakeFiles/CMakeError.log".
I had the same issue and fixed it running cmake as Admin
Those error messages
The C compiler identification is unknown
The CXX compiler identification is unknown
means CMake did find or assume a compiler but it wasn't able to compile a simple test program.
Take a look at CMakeFiles\CMakeError.log and check the error message there to see:
which compiler path/command line CMake did use
what the error message calling the compiler was
e.g. LINK : fatal error LNK1181: cannot open input file 'kernel32.lib'
If you add --debug-trycompile to the cmake call CMake will even keep the files it has tried to test compile (so you can copy/paste/re-run the command line from the error log in your cmd shell).
The last time I had this problem ...
The last time I had this problem was when my Visual Studio 2012 Professional standard installation did not install any Windows SDK (the error log was showing an missing SDK header).
To verify your SDK installation e.g. check that you have any Resource Compiler installed. It should be in a path similar to:
C:\Program Files (x86)\Microsoft SDKs\Windows\v[some version]\bin\RC.Exe
Since I was missing this - or more accurate any SDK - I installed Windows 8.1 SDK (since Visual Studio 2012 does target Windows 8.x) and voila my CMake was able again to compile the (test) programs.
Reference
Does Visual Studio 2012 include the full Windows SDK
CMake Error at CMakeLists.txt:30 (project): No CMAKE_C_COMPILER could be found
I was getting the terminal output:
The C compiler identification is unknown
The CXX compiler identification is unknown
I checked the CMakeError.log output:
\build\CMakeFiles\CMakeError.log
It showed the error:
warning MSB8003: The WindowsSDKDir property is not defined. Some build tools may not be found.
Going back to visual Studio I needed to install the Windows 10 SDK:
After installing the SDK and running cmake it showed:
Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.18363.
The C compiler identification is MSVC 19.28.29334.0
The CXX compiler identification is MSVC 19.28.29334.0
And built successfully!
I had similar problem also, if you are using Microsoft Visual Studio 2012, that might be because of update of KB2781514 is missing.
After I installed following update, CMake start to detect Visual Studio 2012 c/c++ compilers correctly.
http://www.microsoft.com/en-us/download/details.aspx?id=36020
I faced the same problem. Building and running a project from Visual Studio didn't work for me. However following worked for me:
Open command prompt for developers from Visual Studio tools.
Goto the directory where cmake.exe is present.
Run it.
Lets hope it works for you as well.
For some reason, deleting the build folder in my machine, solved the issue.
cmake:
The cmake assume that you set g++ compiler path accurately.In case due any reason if it did't find compiler path{/usr/bin/g++} then it throw an error like:
**The CXX compiler identification is unknown**
So given step will short out this error:
Locate your compiler CXX path{for g++ path under Linux is :/usr/bin/g++}
Set the Compiler Path and export it configuration: PATH=/usr/bin:$PATH;export PATH
Export compiler like : export CXX=/usr/bin/g++-7
Here we assume that g++,cmake,build-essential install in your Linux system...!!
Same problem here with cmake 2.8.12 and visual studio 10. Cmake may not be able to find the compiler. I solved the problem by uninstalling latest version and installed cmake 2.8.10.
I just encounter with this issue, after I uninstalled some MS software.
I fixed it by repair visual studio 2012.
First go to [Control panel], then select visual studio and repair it,things will go right now.
Make sure you select the proper version of visual Studio.
For example, Visual Studio 2012 is version 11.
I had the same problem and I had to use the "File -> Delete Cache", since I accidentally configured CMake to use wrong visual studio version.
If you use CMake 3.4.0, try upgrading to a newer version. A bug concerning this was fixed relatively recently (see the bug report).
Make sure that you have installed Clang tools
open tools -> Get tools and features, select individual components, search cmake, then uninstall cmake and then re-install cmake, when complete, restart your computer.
I was seeing this on ubuntu - issue was cmake was assuming clang++ as c compiler.
CMake Error at /usr/share/cmake-3.10/Modules/CMakeTestCCompiler.cmake:52 (message):
The C compiler
"/usr/bin/clang++-9"
To fix it, export C, C++ compiler paths:
export CC=/usr/bin/clang
export CXX=/usr/bin/clang++

Compiling wxWidgets 2.8.12 and 2.9.3 under Visual Studio 11 Beta

I tried tried to compile wxWidgets and got errors pertaining to missing "wx/setup.h" header file.
wxMSW-2.8.12\include\wx/platform.h(196): fatal error C1083: Cannot open include file: 'wx/setup.h': No such file or directory
Are there simple configuration changes that I can make to allow me to compile the libraries?
Environment
Windows 7 64-bit
Visual C++ 11 Beta
fyi: I have successfully built wxWidgets on this machine using Visual C++ 9.
setup.h is actually in the "msvc" directory next to "wx" in "include". You need to include the msvc folder as well and it should work.
Compiling from command line should work, see http://wxwidgets.blogspot.com/2012/02/building-wxwidgets-with-microsoft.html (although I only tested this with 2.9, not 2.8). Notice that you should use a different COMPILER_PREFIX to avoid conflicts between your existing VC9 build and this one, e.g. nmake -f makefile.vc COMPILER_PREFIX=vc100.
If you use project files then you should check that importing VC9 versions worked correctly, perhaps something bad has happened during the import process.