zoukankan      html  css  js  c++  java
  • 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) 

     

      

      

     

     

     

     

     

     

     

     

     

     

     

  • 相关阅读:
    php 闭包 function use用法
    php序列号和反序列化
    [转]php composer使用
    hex编码,用途是什么,为什么需要hex编码呢?
    美术资源优化/LOD
    ASTC纹理压缩格式详解
    Elastic Stack之 Elasticsearch 6.7.1版本单机版安装、集群版安装
    使用datax将mysql数据同步到ES 附elasticsearchwriter插件
    Java1.8之Lambda表达式
    Java1.8之Lambda表达式、流Stream学习
  • 原文地址:https://www.cnblogs.com/ecoflex/p/10184610.html
Copyright © 2011-2022 走看看