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) 

     

      

      

     

     

     

     

     

     

     

     

     

     

     

  • 相关阅读:
    vba Application.OnTime 定时器
    Linq to XML
    Jquery Ajax+.ashx Json数据格式
    存储过程
    Jquery Ajax +.ashx XML数据格式
    原生态JS  图片滚动
    Standup Timer的MVC模式及项目结构分析
    android的Handler
    Microsoft Office Sharepoint Server 2007数据库日志文件逐渐增大处理笔记
    windows 网络编程学习Winsock API
  • 原文地址:https://www.cnblogs.com/ecoflex/p/10184610.html
Copyright © 2011-2022 走看看