成功解决CMake Error at src/CMakeLists.txt:3 (add_library): Cannot find source file:
目前整个的文件结构如下:
user@user-B460MPOWER:~/work/xinguo/rgbd-slam-tutorial-gx/partI$ tree -L 2
.
├── bin
├── build
│ ├── CMakeCache.txt
│ ├── CMakeFiles
│ ├── cmake_install.cmake
│ ├── Makefile
│ └── src
├── cmake-build-debug
│ ├── CMakeCache.txt
│ ├── CMakeFiles
│ ├── cmake_install.cmake
│ ├── Makefile
│ ├── slam.cbp
│ ├── src
│ └── Testing
├── CMakeLists.txt
├── include
│ └── mylib
├── lib
└── src
├── CMakeLists.txt
├── main.cpp
└── planar.cpp
没有找到是因为头文件配套的实现文件名字写错了。
CMake Error at src/CMakeLists.txt:3 (add_library):
Cannot find source file:
plane.cpp
Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp
.hxx .in .txx
CMake Error: CMake can not determine linker language for target: mylib
CMake Error: Cannot determine link language for target "mylib".
-- Generating done
-- Build files have been written to: /home/user/work/rgbd-slam-tutorial-gx/partI/build
编译时出这个错误,因为cmakelist.txt中add_library()中包含的是src/planer.cpp,而我实际文件是src/planar.cpp,后缀不一样,当然找不到(虽然.cc文件等同于.cpp文件,但是毕竟一个.cc,一个.cpp,名字不一样)。