• Modern C++ Course [Lecture 3] {CMake, Google Test, Namespaces, Classes}


     workflow of cmake:

    edit CMakeLists.txt in the root directory of the project:

    create an empty build folder, and cmake inside it. ".." means the root direction, which should include a "CMakeLists.txt.

     

     run cmake and recive a large bunch of information.  (not showed here)

     check the Makefile, although it's dummy. (have no meaningful code under ../src/ now)

     add two more lines in CMakeLists.txt

    let's make CMake happy

    edit our main func in src

     main.cpp:

     edit the CMake file in the same folder

     build again

     (a combo of "cmake" and "make" under build folder)

     execuate this binary file:

    here, under build folder, a src folder will mimic the structure of the src under root

    add a header file  "hello.h"

    declare and define at the same time now.

     line 3, "./" in "./xxx.h" means only search for this file in this folder. Not a proper way, but will remove the error sign.

     

    cd ../build/

    cmake

    make

    ./src/bin_main

    => Hello function

    since we didn't divide the header file into header and definition, we don't need to modify the makefile, but program can be inefficient, because the compiler will compile the header file again and again.

    cmake doesnt know the header files now, apart from where to search for them.

    angular bracket means will search all the system path, rather than the path of main.cpp

    => get error :

    the topmost cmake:

    => successful building now!

    create a hello.cpp

    delete redundant definition in hello.h

     

    modify the cmake file under root/src 

    make again 

     => Hello function

    create two new files in src

     

      (main func)

     (cmake under src)

     => Hello function

          Blah

    What about dynamic library?

    (add SHARED)

    static library: .a file 

    dynamic library: .so file (cpp and h file can be everywhere in system, and the only way to use it is to first search for it) 

     

      

      

     

     

     

     

     

     

     

     

     

     

     

  • 相关阅读:
    查找 Search
    [HEOI2016/TJOI2016]排序
    [SDOI2011\]染色
    [构造题选讲]
    [LNOI2014]LCA
    [POI2013]LUKTriumphal arch
    java取得某月最后一天
    设置上网代理服务器
    Richfaces改变我的编程方式
    Richfaces Style
  • 原文地址:https://www.cnblogs.com/ecoflex/p/10184610.html
Copyright © 2020-2023  润新知