'Cmake Error: could not load cache

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?



Solution 1:[1]

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:[2]

Remove the CMakeCache.txt and try again. You probably had a bad cmake setup.

Solution 3:[3]

run cmake --configure . it should generate required files.

Solution 4:[4]

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:

enter image description here

Solution 5:[5]

I have faced the same problem and solved it using the terminal.

  1. Delete the cached/configurations files as we will get them again.
  2. To configure the project run cmake .
  3. Build the project using cmake --build .

Solution 6:[6]

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:[7]

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:[8]

For me it helps to select CMake tab (next to Run, TODO) in CLion. Then click the Reload CMakeProject button.

Solution 9:[9]

If you are using Visual Studio 2019, close Visual Studio, delete .vs and out folders then rebuild your project.

Solution 10:[10]

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:[11]

The solution that worked for me using VisualStudio 2017 was choosing: CMake --> Cache --> Generate (from the top menu)

Solution 12:[12]

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:[13]

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:[14]

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)