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) 

     

      

      

     

     

     

     

     

     

     

     

     

     

     

  • 相关阅读:
    C#获取Excel Sheet名称,对特殊字符、重名进行了处理
    10个你必须知道的jQueryMobile代码片段
    HTML 5 学习之应用程序缓存
    JS取地址栏参数的两种方法
    关于AJAX+HTML5+ASHX进行全静态页面的数据交互
    重病后的重生
    非常值得学习的java 绘图板源代码
    C#开发者通用性代码审查清单
    【week3】四人小组项目—东师论坛
    【week2】结对编程-四则运算 及感想
  • 原文地址:https://www.cnblogs.com/ecoflex/p/10184610.html
Copyright © 2011-2022 走看看