CMake Error: The current CMakeCache.txt directory CMakeCache.txt is different than the directory

created at 11-03-2021 views: 3

Problem Description

When you start to learn ROS, you need to compile other people's function packages, and often use other people's workspaces, but various errors will occur during compilation, such as the following directory problems:

CMake Error: The current CMakeCache.txt directory /home/vistar/desktop/catkin_ws/build/CMakeCache.txt is different than the directory /home/vistar/桌面/catkin_ws/build where CMakeCache.txt was created. This may result in binaries being created in the wrong place. If you are not sure, reedit the CMakeCache.txt
CMake Error: The source “/home/vistar/desktop/catkin_ws/src/CMakeLists.txt” does not match the source “/home/vistar/桌面/catkin_ws/src/CMakeLists.txt” used to generate cache. Re-run cmake with a different source directory.
Invoking “cmake” failed.

problem analysis

  • The error prompt translation is that your current CMakeCache.txt file path is different from the CMakeCache.txt path recorded in the compiled file.
    (Maybe when compiling, the compiler will look for the CMakeCache.txt file according to the record, but I don’t understand this.) The second error is also because the original record is inconsistent with the current directory, but it is the CMakeLists.txt file.
  • I have modified the Ubuntu directory name before, maybe because of this.
    At the beginning of the creation of the workspace, CMakeCache.txt and CMakeLists.txt did not exist. They only appeared after a catkin_make compilation. Delete the existing ones and compile again.

solution

  1. Error 1: Delete .../build/CMakeCache.txt and recompile
  2. Error 2: delete .../src/CMakeLists.txt and recompile
    Word
created at:11-03-2021
edited at: 11-03-2021: