slam十四讲--使用cmake(开始slam工程)

新建slambook/ch2文件夹
新建一个helloslam.cpp

#include <iostream>
using namespace std;

int main( int argc, char** argv )
{   

   cout<<"hello slam";
   return 0;
}

再新建一个CMakeLists.txt

#声明要求的cmake 的最低版本
cmake_minimum_required(VERSION 3.5)


#声明一个cmake工程
project ( HelloSLAM)

#添加一个可执行程序
add_executable (helloslam helloslam.cpp)

然后在slambook/ch2路径下

cmake .

显示

-- Configuring done
-- Generating done
-- Build files have been written to: /home/l/project/learning/slambook/ch2

然后

make
[ 50%] Building CXX object CMakeFiles/helloslam.dir/helloslam.cpp.o
[100%] Linking CXX executable helloslam
[100%] Built target helloslam

使用 ./helloslam

另一般会新建build将编译好的文件方在build
所以
在slambook/che2下新建build

mkdir build

然后编译

cd build
cmake ..
make

猜你喜欢

转载自blog.csdn.net/Discoverhfub/article/details/81006233
今日推荐