Cmake Error: could not load cache
CmakeCmake Problem Overview
I'm using Cmake to try to build a project for Eclipse. When I try running Cmake, I get the following error:
Error: could not load cache
Error: Batch build stopped due to Eclipse CDT4 - Unix Makefiles error.
---- Time Elapsed: 3 secs ----
Error: could not load cache
Error: Batch build stopped due to Eclipse CDT4 - Unix Makefiles error.
I'm completely stumped on what might be causing this. I know that I'm running Cmake in the correct directory and the CMakeCache.txt file is present. Could someone point me in the right direction to solve this?
Cmake Solutions
Solution 1 - Cmake
If you are using the CLion, you can use File---"Reload CMake Project".
I meet this problem after using git force pull, and Reload CMake Project solves it.
Solution 2 - Cmake
Remove the CMakeCache.txt and try again. You probably had a bad cmake setup.
Solution 3 - Cmake
run cmake --configure .
it should generate required files.
Solution 4 - Cmake
I ran into this recently using JetBrains CLion and the above instructions were helpful but not directly, I was able to reload the project using the "cog" drop down in the CMake
tab:
Solution 5 - Cmake
I have faced the same problem and solved it using the terminal.
- Delete the cached/configurations files as we will get them again.
- To configure the project run
cmake .
- Build the project using
cmake --build .
Solution 6 - Cmake
If you are absolutely positive that you are running the build command from the binary directory, this error probably means that you have had an issue during the configuration/generation step that you should have ran before trying the build. You can try to configure again to check (cmake your-build-dir)
I would advise running the Gui and trying to load the cache to see if you get a more explicit error (although I doubt it).
Another possibility would be to try to create a new clean build directory and take it from there.
Solution 7 - Cmake
In your example Eclipse must run something like
cmake --build folder_name --target all
and I opt that the folder_name is bad in this case. You probably messed something up in Eclipse.
Solution 8 - Cmake
For me it helps to select CMake tab (next to Run, TODO) in CLion. Then click the Reload CMakeProject button.
Solution 9 - Cmake
If you are using Visual Studio 2019, close Visual Studio, delete .vs
and out
folders then rebuild your project.
Solution 10 - Cmake
I removed the .cxx
and other ide-generated files to the recycle.bin, except app.iml
. Then I restarted Android Studio, and eventually it worked fine.
Solution 11 - Cmake
The solution that worked for me using VisualStudio 2017 was choosing: CMake --> Cache --> Generate (from the top menu)
Solution 12 - Cmake
Apart from the already given answers, it might be due to the wrong commands or in wrong order.
To be precise, for me, it was due to
cmake -B build -G Ninja
cmake --build .
The "cmake --build ." command will throw the Could Not Load Cache error.
The problem is the build directory is given as '.' which doesn't have the cache or whatever files cmake generates, so correct command was 'cmake --build build'... and fixed !
There maybe trillion other ways but my solution was this.
For eg, it happened with the repo -> https://github.com/adi-g15/worldlinesim, though may show the same for other repos too.
Solution 13 - Cmake
For Ubuntu users, provide the source code open-pose path in the CMake-GUI.
P.S I had this issue and my path was not set there.
Solution 14 - Cmake
Most probably the issue is you have not wrote the correct name of the Visual Studio version you have installed during the build file preparation:
cmake .. -G "Visual Studio 16 2019" (note if you have VS 2016 you should change in in there)
Solution 15 - Cmake
The most realistic answer and personal experienced answer is
- If you are using Clion and building files with IDE
- And getting the error Cmake Error: could not load cache
- Because you have accidentally deleted the cache file (like me: permanently and cant get back) or there is other problems or other problems
Then do this:
> Run -> Clean > > Run -> Build
And your project will be working all fine